The others have already given you some excellent answers. I just wanted to point out Regexp::Common::delimited as well as Text::Balanced, which contain functions that implement something like what you are doing. Also, this task sounds like something that one encounters when parsing formats for which parsers might already exist, a common one being Text::CSV. Also, personally I find it easier to write my regex tests as I showed in Re: How to ask better questions using Test::More and sample data.
In reply to Re: Using negative lookahead
by haukex
in thread Using negative lookahead
by ibm1620
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |