in reply to Regular Expression Elegance
This seems to be hunky-dorieBut it isn't. If you start with $value being
you end with $value being"<a href='foo'>bar</a>bla<br>bla<a href='bar'>foo</a>";
You're bitten by the notion that /PAT1'(.*?)'PAT2/ will not end up with a ' in $1."<a href='foo'>bar</a>blabla<a href='bar'>foo</a>";
I'd go with:
while ($value =~ /href='\K([^']*<br>[^']*)(?=')/p) { my ($pre, $post) = (${^PREMATCH}, ${^POSTMATCH}); my $href = $1; $href =~ s/<br>//g; $value = "$pre$href$post"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regular Expression Elegance
by monkie (Novice) on Nov 11, 2008 at 14:25 UTC |