MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Sigil (https://www.mobileread.com/forums/forumdisplay.php?f=203)
-   -   I don't know how to use wilcards and regular expression.... (https://www.mobileread.com/forums/showthread.php?t=74161)

superanima 02-17-2010 08:48 AM

I don't know how to use wilcards and regular expression....
 
how can I search this
Code:

<h2 id="calibre_toc_24">10 METZ</h2>
and replace it with this
Code:

<h2 id="calibre_toc_24">10<br>METZ</h2>
???

also, where can I find something to learn about this wildcard search?

thanks

superanima 02-17-2010 12:47 PM

ok, this expression
Code:

(<h2 id="calibre_toc_\d*">\d*)(\s)
in the find field and this expression
Code:

\1<br>
in the replace field worked for me

Sabardeyn 02-18-2010 09:28 PM

Superanima,

Your formula is probably fine, but just be careful when using RegEx. Because of it's power and versatility, it is very easy to create a formula that seems to do what you want.

The formula could also find some close, but not exact, matches. Unfortunately you only find out about these errors after the fact. Always try to match a unique combination of characters. If your program allows it also use manual search & replace, not automatic. This makes sure you do not accidentally make things harder for yourself. At least until you get a better understanding of RegEx.

Edit: I should mention that I've discovered this the hard way! ;)

LARdT 02-20-2010 07:47 AM

You can find several examples in my blog: http://mipapyreebookreader.blogspot.com/search/label/RegEx

superanima 02-21-2010 10:42 AM

thanks both of you :-)


All times are GMT -4. The time now is 06:37 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.