Thread: Regex examples
View Single Post
Old 08-06-2012, 09:52 PM   #119
theducks
Well trained by Cats
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: 29,818
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by Danger View Post
First thanks for everyones help here. While I haven't posted for help the answers to other peoples problems has helped me as well when I had similar questions. however I have a question that I don't see an answer to.

I am trying to remove a start and end div tag. These span an entire chapter.
Code:
<body>
  <div class="story" id="part-27">
...
  </div>
</body>
I've tried:
FIND
Code:
<div class="story" id="part-\d+">(.*?)</div>
&
Code:
<div class="story" id="part-\d+">(.*)</div>
and a few other variations but Sigil always returns a zero count. Just wondering what I am doing wrong. This isn't the first time I've run into this problem. Before I've just worked around it by working with much smaller bits but I'd like to know just what it is I am doing wrong because as far as I can tell that should work. Using Sigil 0.5.902

EDIT:
Ok it seems that the regex was fine, it just doesn't work in 0.5.902 but does work in 0.5.3 which I don't like using much for finding/replacing because over half the time I get left with a literal \1 instead of the actual text. Which of course I have to UNDO, FIND, REPLACE for each. Easy enough when it's a large block of text, not so easy when it's a word or sentence forcing me to do another FIND for any 1< instances. A REPLACE ALL is just a nightmare if you don't have a backup.
You need to tell it it is multiline

Code:
(?sm)<div class="story" id="part-\d+">(.*?)</div>
theducks is offline   Reply With Quote