Thread: Reg-ex help...?
View Single Post
Old 12-05-2011, 02:43 PM   #1
ElMiko
Evangelist
ElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileRead
 
ElMiko's Avatar
 
Posts: 471
Karma: 65460
Join Date: Jun 2011
Device: Kindle
Reg-ex help...?

Hi, all. I'm back for some additional reg-ex instruction...

I'm trying to remove <div> tags from a document in bulk, but can't seem to figure out what expression I should be using to find them.

Here's a sample of the code I'm working on:

Spoiler:
<div class="calibre1">
<p class="calibre2"><span class="none">Some text that I want to keep.</span></p>
</div>

<div class="calibre1">
<p class="calibre5"><span class="none1">Some DIFFERENT text that I want to keep.</span></p>
</div>


Now, the expression I used (with the intent of replacing it with "\1") was:
Code:
<div class="calibre1">([^<]*)</div>
Naturally, it didn't work ("no results found"). I think I discovered the reason. the "<" in "([^<]*)" is triggered by the first instance of that character, i.e. the "<" in "<p class...". The bad news is that knowing the problem hasn't helped me find the solution. I've tried a bunch of other iterations that either match too much (the entire document) or nothing at all.

Can someone let me know where exactly my brain is letting me down?
ElMiko is offline   Reply With Quote