View Single Post
Old 05-09-2023, 04:49 PM   #1
Vanguard3000
Groupie
Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.
 
Posts: 169
Karma: 474196
Join Date: Jan 2011
Location: Canada
Device: Kobo Libra 2
Regex help: Find instances spanning several paragraphs

I've come across this on several occasions and was curious if there's a good regex for it. A non-specific typical example would be to select an entire <div> or <blockquote>, which could contain any number of paragraphs, such as:

Code:
<div class="foo">
<p>aaa</p>
<p>bbb</p>
[...]
<p>ccc</p>
</div>
Currently, I'd need to do something like:

Code:
<div class="foo">    <p>(.*?)</p>    </div>
then:
Code:
<div class="foo">    <p>(.*?)</p>    <p>(.*?)</p>    </div>
and so on. Ideally I'd like to do:
Code:
<div class="foo">(.*?)</div>
but it doesn't work, I assume due to too much whitespace, returns, etc.

So, I feel like one of the regex settings ought to allow searches to skip whitespace or whatever and this is probably an easy fix, but I'm not sure what it might be.

Also, for the record, I do have the TagMechanic plugin which helps in most situations like this, but in some cases it would be nice for me to be able to iterate through all instances with a regular F&R process.
Vanguard3000 is offline   Reply With Quote