in reply to Regex priorities.
Does this match your expectations?
$s = '<COMMA>pre-stuff<EXHIBITING>some stuff</EXHIBITING>post-stuff</C +OMMA>';; print "$1 :: $2" while $s =~ s[<(\D+)>([^<]*?)</\1>][]gi;; EXHIBITING :: some stuff COMMA :: pre-stuffpost-stuff
Of course, it fails horribly if your non-tag content contains '<':
$s = '<COMMA>pre-stuff<EXHIBITING>some <= stuff</EXHIBITING>post-stuff +</COMMA>';; print "$1 :: $2" while $s =~ s[<(\D+)>([^<]*?)</\1>][]gi;; {zilch here}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex priorities.
by Steve_BZ (Chaplain) on May 28, 2012 at 15:01 UTC |