View Single Post
Old 03-24-2014, 05:44 AM   #1
JLius
Village idiot
JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.
 
JLius's Avatar
 
Posts: 157
Karma: 519566
Join Date: Mar 2014
Location: Belgium
Device: sony PRS T-1
REGEX can't seem to figure it out

Hi all

Came about this old post:
Quote:
Originally Posted by Perkin View Post
If all of the chapters contain exactly the same
Code:
<p class="calibre10"><span class="calibre8 bold calibre11 calibre8">
and then the chapter number followed by
Code:
</span></p>
then search for (regex, minimal)
Code:
<p class="calibre10"><span class="calibre8 bold calibre11 calibre8">(\d+)</span></p>
replace
Code:
<h2>Chapter \1</h2>

I thought this could save me a lot of time cleaning up an epub document. Didn't know about regex, so I gave it a try.

I want to replace <i class="calibre2">words</i> by <em>words</em)
So I searched for <i class="calibre2">(\w+)</i> and replaced it with <em>\1</em>

That worked fine when there was only one word between > <. But when there are more: <i class="calibre2">two words</i>, my seach doesn't find them.

Does w+ only search 1 word? How do I get it to search for any number of words? Do I change the \1 in the replace with * or something else?

Thanks in advance!

JLius
JLius is offline   Reply With Quote