View Single Post
Old 01-23-2011, 11:19 AM   #7
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,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
For learning regular expressions start with what you want to replace and start replacing parts of it with regular expression characters. Meaning you have:

Code:
<div><h4>Book Author</h4><h6>Page 1 of 365</h6></div>
Start by replacing parts that change:

Code:
<div><h4>Book Author</h4><h6>Page \d{1,3} of 365</h6></div>
Then:

Code:
<div>\s*<h4>\s*Book\s*Author\s*</h4>\s*<h6>\s*Page\s*\d{1,3}\s*of\s*365</h6>\s*</div>
And so forth.

Also, the trickiest part of regular expressions is the confusion when it matches things you didn't expect it to match. calibre has a regular expression wizard in the search and replace option section that will show you all matches for your regex in the document. Use this or if you have a text editor that can highlight all matches use it. It will save you a lot of time and trouble.
user_none is offline   Reply With Quote