Grep -- How to match segment containing many lines

Sivakatirswami katir at hindu.org
Sat May 12 17:10:51 EDT 2007


Jim Ault wrote:
> you should look at the (?) directive syntax
> 
> such as (?i) = case sensitive
> (?si) = ignore line endings + case sensitive
> (?Usi) = ungreedy + ignore + sensitive
> 
> I think you want [greedy + ignore line endings] so use
> 
> put "(?s)<div id="linklist">(.*?)</html>" into regEx
> get matchChunk(textBlock,regEx,charpos1,charpos2)
> delete char charpos1 to charpos2 of textBlock
> 
> This should get you close to what you want.
> 
> Jim Ault
> Las Vegas
> 


Jim, thanks... that's it.

(?s)<div id="linklist">(.*?)</html>
does it... and I found the section in the BBEdit help on
"Perl-Style Pattern Extensions"  where all this is
explained...

"s       allow. to match \r"

Marvelous!  The unintuitive part is that this pattern
or "toggle" must begin the entire expression.

Sivakatirswami
www.himalayanacademy.com




More information about the use-livecode mailing list