http://qs321.pair.com?node_id=1060666


in reply to Split with consecutive delimeters

Your words are contradicted by your example. "ab''c" has three elements delimited by 2 delimiters. $VAR2 in the output is not a placeholder for a delimiter, it represents what is between the two delimiters.

If you want to have delimiters also represented in the output, you can use this:

my @arr1 = split("(')", "ab''c");

UDPATE: It seems you want '' to be handled as one delimiter, but translated into empty strings.

my @arr1x = split("('+)", "ab''c"); my @arr1; foreach (@arr1x) { if (/'/) { push @arr1, ('') x length($_); } else { push @arr1, $_; } }

UPDATE2: Arrgh, we are communicating out of sync ;-)

Replies are listed 'Best First'.
Re^2: Split with consecutive delimeters
by nkuduva (Novice) on Nov 01, 2013 at 00:35 UTC
    Gotcha! Thanks for your reply. Your suggestion of split with delimiters in output is what I was looking for.