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

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 07-21-2010, 06:11 AM   #1
Lonas
Junior Member
Lonas began at the beginning.
 
Posts: 5
Karma: 10
Join Date: May 2010
Device: iPad
Question Regex capturing variables

Hi all,

I don't know if I am just doing it wrong but it seems that Sigil currently does not support the selection/capturing of string tokens with a regex to use it later in the Replace/Find dialogue. Is that correct?

I tried the Perl syntax with $1, $2, ... and I also tried cap(1), cap(2), ... and capturedTexts()[1], capturedTexts()[2], ... as specified in the QRegExp documentation (QRegExp is obviously the regex implementation used by Sigil, look here for its documentation on capturing variables: http://doc.qt.nokia.com/3.3/qregexp.html#1-5).

This would be a very important feature for me as I commonly run across badly converted PDF outputs which need to be fixed.

Any ideas? Thanks in advance!
Lonas is offline   Reply With Quote
Old 07-21-2010, 08:27 AM   #2
capidamonte
Not who you think I am...
capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
capidamonte's Avatar
 
Posts: 374
Karma: 30099
Join Date: Jan 2010
Location: Honolulu
Device: PocketBook 360 -- Ivory
Try \1 \2
capidamonte is offline   Reply With Quote
Advert
Old 07-21-2010, 08:37 AM   #3
Lonas
Junior Member
Lonas began at the beginning.
 
Posts: 5
Karma: 10
Join Date: May 2010
Device: iPad
Excellent, that worked! Thanks a lot for the quick answer!

I suggest putting that in the documentation, maybe other users might find it helpful as well...
Lonas is offline   Reply With Quote
Old 07-21-2010, 04:24 PM   #4
calvin
DRM remover
calvin began at the beginning.
 
calvin's Avatar
 
Posts: 84
Karma: 10
Join Date: Dec 2009
Location: North of Germany
Device: Kindle 3, 4 & Touch, iPhone/iPad, Hanvon N516 (OpenInkpot)
Hi,
I have exactly the same problem but \1 \2 does not work either...

I am trying to remove additional brakes:
find what: [a-z0-9]<br class="calibre 4" />
replace with: \1

all I get is the character which is found by the first search replaced with "\1", nothing else.

using sigil 0.2.3
calvin is offline   Reply With Quote
Old 07-21-2010, 10:00 PM   #5
capidamonte
Not who you think I am...
capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
capidamonte's Avatar
 
Posts: 374
Karma: 30099
Join Date: Jan 2010
Location: Honolulu
Device: PocketBook 360 -- Ivory
You've got to put something in parentheses:

find: ([a-z0-9])<br class-"calibre 4" />
replace: \1

This will find a lower-case letter or number followed by the <br ...> and replace it with whatever the lower-case letter or number is. The <br ...> will disappear.

BTW, I'd add a space to the replace -- \1\s -- as changing multiple spaces is easy, but spell checking mis-joined words is not.
capidamonte is offline   Reply With Quote
Advert
Old 07-22-2010, 06:48 AM   #6
calvin
DRM remover
calvin began at the beginning.
 
calvin's Avatar
 
Posts: 84
Karma: 10
Join Date: Dec 2009
Location: North of Germany
Device: Kindle 3, 4 & Touch, iPhone/iPad, Hanvon N516 (OpenInkpot)
THANKS! that worked

I googled several pages but nowhere found the tip with the parantheses...

one other question, if I search for "a-z" it will find capital letters too. That seems to me not correct or?

thanks
calvin

Last edited by calvin; 07-22-2010 at 08:56 AM.
calvin is offline   Reply With Quote
Old 07-22-2010, 04:21 PM   #7
capidamonte
Not who you think I am...
capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
capidamonte's Avatar
 
Posts: 374
Karma: 30099
Join Date: Jan 2010
Location: Honolulu
Device: PocketBook 360 -- Ivory
Sets of parentheses, from left to right, correspond to the numbers you use in the replace: first set -- \1, second set -- \2, etc.

Quote:
one other question, if I search for "a-z" it will find capital letters too.
Not correct, as you suspect. Click the "More" button in the replace dialog. Make sure the "Match Case" radio button is checked.
capidamonte is offline   Reply With Quote
Old 07-22-2010, 05:29 PM   #8
calvin
DRM remover
calvin began at the beginning.
 
calvin's Avatar
 
Posts: 84
Karma: 10
Join Date: Dec 2009
Location: North of Germany
Device: Kindle 3, 4 & Touch, iPhone/iPad, Hanvon N516 (OpenInkpot)
thanks for your help!

calvin
calvin is offline   Reply With Quote
Old 07-25-2010, 07:58 AM   #9
Valloric
Created Sigil, FlightCrew
Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.
 
Valloric's Avatar
 
Posts: 1,979
Karma: 350515
Join Date: Feb 2008
Device: Kobo Aura
Quote:
Originally Posted by Lonas View Post
I suggest putting that in the documentation, maybe other users might find it helpful as well...
It's already in the documentation, and has been for a while.
Valloric is offline   Reply With Quote
Old 08-14-2010, 04:05 PM   #10
Lonas
Junior Member
Lonas began at the beginning.
 
Posts: 5
Karma: 10
Join Date: May 2010
Device: iPad
Quote:
Originally Posted by Valloric View Post
It's already in the documentation, and has been for a while.
Oh okay sorry, I did not see that - or more accurately did not understand that back-reference means exactly this thing
Lonas is offline   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
What a regex is Worldwalker Calibre 20 05-10-2010 06:51 AM
Regex help... Bobthebass Workshop 6 04-26-2009 04:54 PM
700 or K2 for highlighting, capturing & take notes + whole family Douglasco Which one should I buy? 7 02-25-2009 09:46 AM
Noob: just getting my head around all the variables KAM Sony Reader 16 02-04-2009 07:16 PM
Entertaining, capturing and inspiring soul teaser irapas1 Reading Recommendations 0 10-25-2003 08:15 AM


All times are GMT -4. The time now is 10:32 AM.


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