Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Split with consecutive delimeters

by jethro (Monsignor)
on Nov 01, 2013 at 00:27 UTC ( [id://1060666]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1060666]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2025-07-08 23:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.