Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Regex to add space after punctuation sign

by Hena (Friar)
on Jan 08, 2004 at 09:53 UTC ( #319768=note: print w/replies, xml ) Need Help??


in reply to Regex to add space after punctuation sign

I'm not quite sure got this right but heres my try (both dot and comma is used).
s/(?<=\D)([,.]) *(?=\D)/$1 /g;
Tested with this.
perl -e '$a="1,23, 23, df,sd.asf,\"\"";$a=~s/(?<=\D)([,.]) *(?=\D)/$1 +/g;print "$a\n";' 1,23, 23, df, sd. asf, ""

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://319768]
help
Chatterbox?
[ikegami]: I tunashish, you tunafish, we all tunafish!
[thezip]: Why all the screaming???
[Discipulus]: tunashish is a smoking test?
[oiskuu]: .oO( Lots of poorly tuned pianos await in thezip's hell. )
[thezip]: Apparently I have already reached my destination...
[erix]: pianola's :P

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2017-11-17 19:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (271 votes). Check out past polls.

    Notices?