in reply to Re: Complex Splitting
in thread Complex Splitting

In perl 5.10, you don't need to do backflips to get away from the "extra" captures. (?^...|...) means the captures get renumbered so here both are $1. Only one ever actually matches at any time so there's no conflict.

push @array, $1 while $str =~ /(?^(\w+)|\[(\w+)\])/g;

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊