in reply to pattern match of first occurance
Your match (.+) is greedy so it will match as much as possible, i.e. up to the second </year>. Make it non-greedy with the addition of a question mark.
$ perl -E ' > $var = q{<x><year>2010<day>5</day></year><month>January</month> <day +>31</day>, <year>2010</year></x>}; > say $1 if $var =~m{<year>(.+?)</year>};' 2010<day>5</day> $
I hope this is helpful.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: pattern match of first occurance
by rdfield (Priest) on Jul 08, 2010 at 13:57 UTC | |
by deMize (Monk) on Jul 08, 2010 at 20:47 UTC | |
by rdfield (Priest) on Jul 15, 2010 at 15:06 UTC |