You're better of using a matching regex rather than a split:
@arr = $str =~ /(\w|\[\w+\])/g;
Update: thanks to monarch for pointing this out. The above leaves the brackets behind. One option is to split the capture and filter out the undefs thus:
@arr = grep $_, $str =~ /(\w)|\[(\w+)\]/g;
--
Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ?
(Missquoting Janis Joplin)
In reply to Re: Complex Splitting
by rinceWind
in thread Complex Splitting
by neversaint
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |