A handy rule to know about Perl's regular expressions is that a regular expression will always match the leftmost longest match, and not the overall longest match. If you want a good treatise on how regular expressions work, I recommend the "Owl Book". Personally, I found the 1st edition quite good for Perl. The second edition adds Unicode and the third edition didn't add much beyond that, so in my opinion, if you find an older edition, it'll help you just as well.
In reply to Re^5: can I make my regexp match first pattern instead of last?
by Corion
in thread can I make my regex match first pattern instead of last?
by kleucht
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |