in reply to Re^2: Complex Splitting
in thread Complex Splitting

Yes, I regretted the word "lot" as soon as I'd posted, made it sound as if I'd sweated blood writing it. Although I like the simpler approach of your solution there is one problem with it; it doesn't get rid of the square brackets, which was required by the OP.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^4: Complex Splitting
by Roy Johnson (Monsignor) on Feb 07, 2007 at 01:46 UTC
    Hasty reading on my part. Not capturing the brackets is as simple as leaving them outside the capturing parentheses:
    @array = grep defined, split /\[(.*?)\]|/;

    Caution: Contents may have been coded under pressure.