Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Split with consecutive delimeters

by jethro (Monsignor)
on Nov 01, 2013 at 00:27 UTC ( #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
Node Status?
node history
Node Type: note [id://1060666]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2020-06-01 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (11 votes). Check out past polls.

    Notices?