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 01-18-2012, 04:07 AM   #1
Capricorn
Member
Capricorn began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Jan 2012
Device: Iriver Story HD
wildcards in search-replace sigil 0.4905?

Hi everyone,

I am a beginner in the world of ebooks. I bought my first ebook reader in dec 2011 (Bookeen Opus). Hence I also started to use sigil 0.4.2. recently.

First of all, thanks to all the people that develop sigil. Very useful app. Thanks.

I have been using search and replace a lot, especially with wildcards.

Yesterday I installed Sigil 0.4.905 and wanted to use search-replace. But the wildcard option does not seem to be present anymore.

Is this by design? Or not? I like wildcards. Regex seems to be very, very complicated.

Last edited by Capricorn; 01-18-2012 at 04:12 AM.
Capricorn is offline   Reply With Quote
Old 01-18-2012, 10:20 AM   #2
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 3,183
Karma: 7180223
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-300, PRS-T1
Regex is much better than wildcards and easier to control. Put some effort in it, and you will see the benefit.
Toxaris is offline   Reply With Quote
Old 01-18-2012, 10:45 AM   #3
theducks
Grand Sorcerer
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: 15,270
Karma: 6022733
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by Capricorn View Post
Hi everyone,

I am a beginner in the world of ebooks. I bought my first ebook reader in dec 2011 (Bookeen Opus). Hence I also started to use sigil 0.4.2. recently.

First of all, thanks to all the people that develop sigil. Very useful app. Thanks.

I have been using search and replace a lot, especially with wildcards.

Yesterday I installed Sigil 0.4.905 and wanted to use search-replace. But the wildcard option does not seem to be present anymore.

Is this by design? Or not? I like wildcards. Regex seems to be very, very complicated.
REGEX is a Caged Wild card
Go read Manichean's REGEX Tutorial: http://www.mobileread.com/forums/sho...d.php?t=118569
theducks is offline   Reply With Quote
Old 01-18-2012, 06:13 PM   #4
Capricorn
Member
Capricorn began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Jan 2012
Device: Iriver Story HD
Thank you for that info.

I had a read through manichean's tutorial. That was very useful. Then I went on to the python docs and got utterly lost. It seems like a complete programming language.
As my purpose is to edit some epub books, and not programming, I decided there had to be a better way. Hence I searched on the internet for a regex generator.

I did find some:

1. regexbuddy and regexmagic from the company Just Great Software

2. expresso from ultrapico

As expresso was free, I decided to go for that one.

Then I built the following regex, using expresso, for find and replace

find: </p>[\s]+<p class="calibre2">
replace: \s

When I executed this in sigil, it would find the string in my codeview file, but it did NOT replace it, when I pushed the single replace arrow. If I pushed the replace all button, it worked, but it put in the string \s instead of a blank space.
If I used a blank space in the replace field, again, it did nothing on single replace, but on replace all button, it executed properly with a blank space.

What am I doing wrong?
Capricorn is offline   Reply With Quote
Old 01-18-2012, 06:24 PM   #5
theducks
Grand Sorcerer
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: 15,270
Karma: 6022733
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by Capricorn View Post
Thank you for that info.

I had a read through manichean's tutorial. That was very useful. Then I went on to the python docs and got utterly lost. It seems like a complete programming language.
As my purpose is to edit some epub books, and not programming, I decided there had to be a better way. Hence I searched on the internet for a regex generator.

I did find some:

1. regexbuddy and regexmagic from the company Just Great Software

2. expresso from ultrapico

As expresso was free, I decided to go for that one.

Then I built the following regex, using expresso, for find and replace

find: </p>[\s]+<p class="calibre2">
replace: \s

When I executed this in sigil, it would find the string in my codeview file, but it did NOT replace it, when I pushed the single replace arrow. If I pushed the replace all button, it worked, but it put in the string \s instead of a blank space.
If I used a blank space in the replace field, again, it did nothing on single replace, but on replace all button, it executed properly with a blank space.

What am I doing wrong?
Nothing
replace single is broken in 905
theducks is offline   Reply With Quote
Old 01-18-2012, 07:22 PM   #6
congngo
Member
congngo began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Apr 2011
Device: kindle dx
2 things you did wrong

1. First you using the brackets instead of parentheses

</p>(\s)+<p class="calibre2">

2. For replacement you need to change \s to \1. \1 represents (\s) from find

Need to learn about basic of regex.

Last edited by congngo; 01-18-2012 at 07:27 PM. Reason: grammar
congngo is offline   Reply With Quote
Old 01-19-2012, 03:51 AM   #7
Capricorn
Member
Capricorn began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Jan 2012
Device: Iriver Story HD
theducks: yes, it seems to be broken. I went back to sigil 0.4.2 and single replace worked again.

congngo: thanks for pointing this out. I went back to expresso and redid the regex. It turned out I had made mistakes, as I am still learning how the product works. Expresso this time produced the following:

</p>\s+<p class="calibre2">

I put that string into the find of sigil 0.4.2.
In replace neither \s or \1 worked. Just putting in the blank space by pressing the space bar on the keyboard did the trick. Replacing single items now works well with my regex, at least in sigil 0.4.2.

If I will ever learn regex properly, is not certain at all, as it seems to be hours of work for something that should be simple (at least using basic wildcards). For now, I will continue to experiment with expresso, and keep searching for posts on regex in this forum. I assume once I have my collection of regex's that work for most things, it will be sufficient.

Thanks for all the help.
Capricorn is offline   Reply With Quote
Old 01-19-2012, 04:57 AM   #8
WS64
WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.
 
WS64's Avatar
 
Posts: 590
Karma: 506380
Join Date: Aug 2010
Location: Germany
Device: Kobo Aura / Bookeen Frontlight / Kobo Mini / Kindle 3 / Nook Color
Quote:
Originally Posted by Capricorn View Post
</p>\s+<p class="calibre2">

I put that string into the find of sigil 0.4.2.
In replace neither \s or \1 worked.
\1 did not work because there was nothing that \1 goes back to.
\1 will use the first match found in parantheses, but there were no parantheses.

\s did not work because this is a placeholder for white spaces (e.g. blanks and tabs). You can't replace anything with \s since it is not a vaild character like the blank itself.

On the other hand it should have worked with congngo's example
</p>(\s)+<p class="calibre2">
and replace with \1 since in this case \1 represents the charatcer found by \s (note that this is NOT \s but a blank or a tab or whatever!)

Last edited by WS64; 01-19-2012 at 05:01 AM.
WS64 is offline   Reply With Quote
Old 01-19-2012, 06:56 AM   #9
Capricorn
Member
Capricorn began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Jan 2012
Device: Iriver Story HD
WS64: thank you very much for that clarification. Now I understand the \1. It is just a variable that takes the value of whatever is in the brackets.

It also makes me understand that I will have to learn more about regex. Just using the expresso app is not enough. However, from the little bit I have read left and right, and understood, there seem to be many versions of regex.

So, which version should I learn?
And is it correct that calibre and sigil use different regex versions?
Capricorn is offline   Reply With Quote
Old 01-19-2012, 07:15 AM   #10
WS64
WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.WS64 ought to be getting tired of karma fortunes by now.
 
WS64's Avatar
 
Posts: 590
Karma: 506380
Join Date: Aug 2010
Location: Germany
Device: Kobo Aura / Bookeen Frontlight / Kobo Mini / Kindle 3 / Nook Color
oops, mixed up brackets and parantheses (it's not my native language...)
Glad you found out by yourself
I learned regex by this excellent tutorial: http://www.regular-expressions.info/tutorial.html
I am still not sure which regex version Sigil uses (especially since there was a change from 0.4.2 to 0.4905), but until you reach the differences its a long way, don't worry about this now. If unsure stick with the Perl 5 version, it's the most popular one.
WS64 is offline   Reply With Quote
Old 01-19-2012, 08:23 AM   #11
Perkin
Guru
Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.
 
Perkin's Avatar
 
Posts: 655
Karma: 64171
Join Date: Sep 2010
Location: Kent, England, Sol 3, ZZ9 plural Z Alpha
Device: Sony PRS-300, Kobo Aura HD, iPad (Marvin)
Quote:
Originally Posted by WS64 View Post
I learned regex by this excellent tutorial: http://www.regular-expressions.info/tutorial.html
That's also from the people who made regexbuddy and regexmagic - Just Great Software, and they do a few other programs.
Perkin is offline   Reply With Quote
Old 01-19-2012, 09:14 AM   #12
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,473
Karma: 1053245
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
Versions <= 0.4.2 use QRegExp. QRegExp is very limited and does not support a number of things. To name a fe: look behind, start of line ^ and end of line $. QRegExp is really off in it's own world and you're best bet is to study the QRegExp documentation to understand what it supports.

Versions >=0.4.901 use PCRE.

Quote:
Originally Posted by PCRE
that implement regular expression pattern matching using the same syntax and semantics as Perl 5.
Perl actually supports two regex engines. A pure Perl one and PCRE. There are slight differences between these two but for all intents and purposes they are the same.

Sigil's regex support is pretty much everything Python and most things from Perl. For searching, I can't think of anything (other than embedding Perl code) that isn't supported. Replace does not support a few things: \Q, \x, \N, \o.
user_none is offline   Reply With Quote
Old 01-19-2012, 01:13 PM   #13
Capricorn
Member
Capricorn began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Jan 2012
Device: Iriver Story HD
Ah...again great info.

Thanks. That tutorial will keep me occupied for many months and regex will probably give me some pretty bad headaches meanwhile. On to regex horizons...arrgghhh.
Capricorn is offline   Reply With Quote
Old 01-19-2012, 09:22 PM   #14
st_albert
Fanatic
st_albert has top level security clearance to Area 51.st_albert has top level security clearance to Area 51.st_albert has top level security clearance to Area 51.st_albert has top level security clearance to Area 51.st_albert has top level security clearance to Area 51.st_albert has top level security clearance to Area 51.st_albert has top level security clearance to Area 51.st_albert has top level security clearance to Area 51.st_albert has top level security clearance to Area 51.st_albert has top level security clearance to Area 51.st_albert has top level security clearance to Area 51.
 
Posts: 552
Karma: 94420
Join Date: Feb 2010
Device: none
PCRE is really not so bad if you take it in bite-sized doses. Stop when your brain reaches its softening point; don't wait 'till it melts. You can probably do most of what you want with very simple regular expressions.
st_albert 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
Search & Replace "wildcards"? LoveMyKobo Calibre 3 05-26-2011 07:12 PM
search and replace - drops blanks in replace ? cybmole Conversion 10 03-13-2011 04:07 AM
Search and replace in 0.2.0 paulpeer Sigil 7 03-13-2010 12:59 PM
wildcards in sigil bobcdy Sigil 2 12-18-2009 11:19 PM
Why no search and replace? charleski Sigil 10 11-24-2009 05:13 PM


All times are GMT -4. The time now is 11:19 PM.


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