Steve_BZ has asked for the wisdom of the Perl Monks concerning the following question:
Hi Guys,
I have a regex designed to pick out some XML tags.
A typical string might look like this:
<COMMA><EXHIBITING></EXHIBITING></COMMA>
I want to process the smallest and inner-most pair of tags first (ie, in this case <EXHIBITING></EXHIBITING>).
I am using the regex:
my $r = '\<(\D+)\>(.*?)(\<\/\1\>)'; while ($loc_diagnoses_text =~ m/$r/gi){ ... processing stuff .... }
But it is processing the <COMMA><COMMA> pair first. How do I fix this?
Regards
Steve
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regex priorities.
by BrowserUk (Patriarch) on May 28, 2012 at 01:20 UTC | |
by Steve_BZ (Chaplain) on May 28, 2012 at 15:01 UTC | |
Re: Regex priorities.
by Anonymous Monk on May 28, 2012 at 01:28 UTC | |
by Steve_BZ (Chaplain) on May 28, 2012 at 15:05 UTC | |
by Anonymous Monk on Jun 01, 2012 at 06:38 UTC |
Back to
Seekers of Perl Wisdom