Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Insert comma after every character

by Ratazong (Monsignor)
on Apr 21, 2010 at 13:45 UTC ( #836063=note: print w/replies, xml ) Need Help??


in reply to Insert comma after every character

TIMTOWTDI.

my $str = "ABCDE"; print join(",",split(//,$str));

The code above enters a comma after every character, except the last one (as shown in your example). However it does not distinguish if your character is between [A..Za..z].

If you want to stick to your solution (using a regex), replace \d by \w. (\d is for numbers.) However your solution adds a comma after the last character.

HTH, Rata

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2022-12-10 02:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?