Register Guidelines E-Books Search Today's Posts Mark Forums Read

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
Guru
phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.
 
Posts: 811
Karma: 156340
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: 23,191
Karma: 24100002
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: K4NT, Galaxy Tab A, Kobo Aura2
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
Connoisseur
retiredbiker is faster than slow light.retiredbiker is faster than slow light.retiredbiker is faster than slow light.retiredbiker is faster than slow light.retiredbiker is faster than slow light.retiredbiker is faster than slow light.retiredbiker is faster than slow light.retiredbiker is faster than slow light.retiredbiker is faster than slow light.retiredbiker is faster than slow light.retiredbiker is faster than slow light.
 
retiredbiker's Avatar
 
Posts: 87
Karma: 29896
Join Date: May 2013
Location: Ontario, Canada
Device: Kindle KB, Oasis, Ubuntu, 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: 282
Karma: 426060
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook Touch HD
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
Guru
phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.
 
Posts: 811
Karma: 156340
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:	47
Size:	109.7 KB
ID:	169667   Click image for larger version

Name:	Capture3.JPG
Views:	51
Size:	44.6 KB
ID:	169668  
phossler is offline   Reply With Quote
Advert
Old 02-12-2019, 09:11 PM   #6
phossler
Guru
phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.
 
Posts: 811
Karma: 156340
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:	62
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: 282
Karma: 426060
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook Touch HD
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
Guru
phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.
 
Posts: 811
Karma: 156340
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:	33
Size:	151.1 KB
ID:	169676   Click image for larger version

Name:	After Replace.JPG
Views:	44
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: 23,191
Karma: 24100002
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: K4NT, Galaxy Tab A, Kobo Aura2
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
Guru
phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.
 
Posts: 811
Karma: 156340
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:	47
Size:	163.9 KB
ID:	169680   Click image for larger version

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

Name:	AfterReplace2.JPG
Views:	33
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: 282
Karma: 426060
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook Touch HD
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
Guru
phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.
 
Posts: 811
Karma: 156340
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: 282
Karma: 426060
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook Touch HD
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:	59
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
Guru
phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.phossler can grok the meaning of the universe.
 
Posts: 811
Karma: 156340
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:	35
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: 23,191
Karma: 24100002
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: K4NT, Galaxy Tab A, Kobo Aura2
Maybe you could have your search use the 'OR' type regex
(aword|bword|cword|dword)
theducks is online now   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 05:02 PM.


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