Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 02-12-2019, 11:46 AM   #1
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Is there a way to use the selection in a Saved Search?

Editing a book with a number of foreign words repeated in many places that I wanted to bracket in <i>foreign_word</i>

I was using Find: (foreign_word#1), Replace: <i>\1</i>

Get the next word or phrase, repeat

Occurred to me that if I had a Saved Search that would use the Selected text:

Find: ($Selected), Replace: <i>\1</i>

then I could just select the text, run the search, select next text, run search, repeat

Last edited by phossler; 02-12-2019 at 12:48 PM.
phossler is offline   Reply With Quote
Old 02-12-2019, 01:41 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,934
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by phossler View Post
Editing a book with a number of foreign words repeated in many places that I wanted to bracket in <i>foreign_word</i>

I was using Find: (foreign_word#1), Replace: <i>\1</i>

Get the next word or phrase, repeat

Occurred to me that if I had a Saved Search that would use the Selected text:

Find: ($Selected), Replace: <i>\1</i>

then I could just select the text, run the search, select next text, run search, repeat
You can bring up the saved searches via Search → Saved searches. This will present you with a list of search and replace expressions that you can apply. You can even select multiple entries in the list by holding down the Ctrl Key while clicking so as to run multiple search and replace expressions in a single operation.

Last edited by BetterRed; 02-12-2019 at 03:34 PM. Reason: Couldn't read Lime
theducks is online now   Reply With Quote
Advert
Old 02-12-2019, 02:32 PM   #3
retiredbiker
Evangelist
retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.
 
retiredbiker's Avatar
 
Posts: 447
Karma: 3886916
Join Date: May 2013
Location: Ontario, Canada
Device: Kindle KB, Oasis, Pop_Os!, Jutoh, Kobo Forma
Quote:
Originally Posted by theducks View Post
You can even select multiple entries in the list by holding down the Ctrl Key while clicking so as to run multiple search and replace expressions in a single operation.
I learn something every day. Thanks!
retiredbiker is offline   Reply With Quote
Old 02-12-2019, 05:59 PM   #4
jbacelar
Interested in the matter
jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.
 
jbacelar's Avatar
 
Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
Quote:
Originally Posted by phossler View Post
Occurred to me that if I had a Saved Search that would use the Selected text:
In Regex mode

1º- Search: (.+)
2º- Replace: <i>\1</i>
3º- Select the word.
4º- Mark selected text
5º- Press the Search button
6º- Press the Replace button

And that's it.
jbacelar is offline   Reply With Quote
Old 02-12-2019, 09:09 PM   #5
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Quote:
Originally Posted by theducks View Post
You can bring up the saved searches via Search → Saved searches. This will present you with a list of search and replace expressions that you can apply. You can even select multiple entries in the list by holding down the Ctrl Key while clicking so as to run multiple search and replace expressions in a single operation.
Yes, I understand that part. But I was wondering about something more flexible that would allow me to use the same Stored search, but be 'smart enough' to use the selected text as the Find.

As example, the same store search using _SELECTION_ in Find What could be used in both cases just be selecting the word and running the same Store Search
Attached Thumbnails
Click image for larger version

Name:	Capture2.JPG
Views:	215
Size:	109.7 KB
ID:	169667   Click image for larger version

Name:	Capture3.JPG
Views:	214
Size:	44.6 KB
ID:	169668  
phossler is offline   Reply With Quote
Advert
Old 02-12-2019, 09:11 PM   #6
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Quote:
Originally Posted by jbacelar View Post
In Regex mode

1º- Search: (.+)
2º- Replace: <i>\1</i>
3º- Select the word.
4º- Mark selected text
5º- Press the Search button
6º- Press the Replace button

And that's it.
I tried that, but it doesn't seem to just bracket the marked word
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	224
Size:	112.5 KB
ID:	169669  
phossler is offline   Reply With Quote
Old 02-13-2019, 02:25 AM   #7
jbacelar
Interested in the matter
jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.
 
jbacelar's Avatar
 
Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
Did you press the Find button and then the Replace button?
jbacelar is offline   Reply With Quote
Old 02-13-2019, 10:14 AM   #8
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Yes

Double Clicked the word (Oktober) to select just the word, Ctrl-Shift-M to Mark it, and clicked Saved Search (Test) to [Find]

Them Saved Search [Replace]

Looks like the rest of the paragraph gets the <i> … </i> and not just the one word I was looking for

Interestingly, it seems like the Marked area was extended to the rest of the paragraph also
Attached Thumbnails
Click image for larger version

Name:	AfterFind.JPG
Views:	256
Size:	151.1 KB
ID:	169676   Click image for larger version

Name:	After Replace.JPG
Views:	207
Size:	159.0 KB
ID:	169677  
phossler is offline   Reply With Quote
Old 02-13-2019, 11:10 AM   #9
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,934
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by phossler View Post
Yes

Double Clicked the word (Oktober) to select just the word, Ctrl-Shift-M to Mark it, and clicked Saved Search (Test) to [Find]

Them Saved Search [Replace]

Looks like the rest of the paragraph gets the <i> … </i> and not just the one word I was looking for

Interestingly, it seems like the Marked area was extended to the rest of the paragraph also
(.+) says capture everything
I think you want something less 'grabby' like (\w+)
theducks is online now   Reply With Quote
Old 02-13-2019, 11:49 AM   #10
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
It's a little awkward since it only seems to work with the word after the empty text cursor (insertion point)

I have to put the cursor before the word, Find and Replace. That's OK -- just counter-intuitive

It doesn't work for a selected phrase; it just Finds the single word after the selected phrase, and applies the Replace to just that word

I'm guessing that even RegEx has no way to 'read' what ever the selected text is, so that was where my thought process conops of using a 'marker'(e.g. _SELECTION_) which would use whatever the selected text is
Attached Thumbnails
Click image for larger version

Name:	BeforeFind1.JPG
Views:	205
Size:	163.9 KB
ID:	169680   Click image for larger version

Name:	AfterReplace1_BeforeFind2.JPG
Views:	196
Size:	152.8 KB
ID:	169681   Click image for larger version

Name:	AfterReplace2.JPG
Views:	185
Size:	158.4 KB
ID:	169682  
phossler is offline   Reply With Quote
Old 02-13-2019, 12:02 PM   #11
jbacelar
Interested in the matter
jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.
 
jbacelar's Avatar
 
Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
Quote:
Originally Posted by phossler View Post
Interestingly, it seems like the Marked area was extended to the rest of the paragraph also
Naturally, you must select, previously, search in Marked text.
jbacelar is offline   Reply With Quote
Old 02-13-2019, 12:14 PM   #12
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
I understand that part (now), but that still only Replaces that single instance of marked text

The other occurrences in the document are not replaced

So in my "Oktober" test case, the marked instance does get replaced by <i>Oktober</i>, but the other 199 occurences of "Oktober" do not
phossler is offline   Reply With Quote
Old 02-13-2019, 01:07 PM   #13
jbacelar
Interested in the matter
jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.
 
jbacelar's Avatar
 
Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
Quote:
Originally Posted by phossler View Post
The other occurrences in the document are not replaced

Oh! okay.
Then I think we should use the universal copy and paste (in parentheses, see image).
Without marking anything.
Attached Thumbnails
Click image for larger version

Name:	Captura.JPG
Views:	258
Size:	58.1 KB
ID:	169688  

Last edited by jbacelar; 02-13-2019 at 01:10 PM.
jbacelar is offline   Reply With Quote
Old 02-13-2019, 03:44 PM   #14
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
That sounds interesting -- I could make that work.

Is that a different screen from the one attached? I couldn't find one that looked close

Few extra steps (copy the word(s) & paste CAREFULLY between the (..) )

It's be a little smoother if _SELECTED_ or something was canned in the stored search, but your idea is pretty good

I have to add some more Replaces to handle words in different languages, something like

Find: (……)

Replace: <span lang="de">\1</span>



Thanks
Attached Thumbnails
Click image for larger version

Name:	Not Bad.JPG
Views:	206
Size:	147.9 KB
ID:	169694  

Last edited by phossler; 02-13-2019 at 03:55 PM.
phossler is offline   Reply With Quote
Old 02-13-2019, 04:27 PM   #15
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,934
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Maybe you could have your search use the 'OR' type regex
(aword|bword|cword|dword)
theducks is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference in Manual Search and Saved Search phossler Editor 4 10-04-2015 12:17 PM
A wee request regarding search notification (and file selection) sherman Editor 1 04-06-2014 10:50 AM
Sending selection from Search & Replace to different fields? MelBr Calibre 2 03-05-2013 01:00 PM
Saved Search: How 2 theducks Library Management 3 11-27-2012 02:10 PM
Need help setting up a saved search ficbot Calibre 1 07-10-2010 02:10 PM


All times are GMT -4. The time now is 06:03 AM.


MobileRead.com is a privately owned, operated and funded community.