Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Split at multiple delimiters and get the delimiter

by jeffa (Chancellor)
on Mar 01, 2011 at 21:27 UTC ( #890826=note: print w/ replies, xml ) Need Help??


in reply to Split at multiple delimiters and get the delimiter

Just add parens:

split /(:|%|;)/
and the delimiters will be captured ... but why put them in another array? Surely you won't be able to line them back up again ...

Update: regardless of why, you could do something like so:

/\W/ ? push @a,$_ : push @b,$_ for split /(:|%|;)/
Where @a would contain the delimiters and @b contains the data ...

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)


Comment on Re: Split at multiple delimiters and get the delimiter
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-07-23 22:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (153 votes), past polls