P is for Practical | |
PerlMonks |
Re^5: Regex problems using '|'by moritz (Cardinal) |
on Jul 22, 2008 at 11:04 UTC ( [id://699265]=note: print w/replies, xml ) | Need Help?? |
If I understood your earlier reply correctly, the regex does match (with the alternation), but it doesn't match the way you want. That's a big difference, and what I tried to explain to you.
That's the behavior I want with regards to the rest of the records. After looking at the updated data I think that you need two regexes for that:
The output is:
The trick is to use the /g-modifier on the first regex although it matches only once. That way pos $str will not be reset, and the next regex match starts where the previous left off. Also note that ^ will anchor to the start of the string (not to the start of a line) unless the /m modifier is present.
In Section
Seekers of Perl Wisdom
|
|