in reply to Regex Report
So that what was previously in the (?2= .* ) would be returned.# parses text like: # name = japhy age = "22" lang = 'Perl' # into a hash... but doesn't capture the quotes! my %data = $text =~ m{ ([^=\s]+) \s* = \s* (?: (?3= ['"] ) (.*? ) \3 | ( \S+ ) ) }xg;
This case might be resolved in other ways,Sorry couldn't help presenting one:
while ( <DATA> ) { my %data = $_ =~ m{ ([^=\s]+) \s* = \s* ["']?( (?<=')[^']* | (?<=")[^"]* | \S+ )["']? }xg;
-enlil
(as a side note I would have to agree with demerphq that named captures would be cool as well)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex Report
by japhy (Canon) on Jun 28, 2004 at 03:40 UTC |