Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Regex to add space after punctuation sign

by grinder (Bishop)
on Jan 08, 2004 at 08:42 UTC ( #319747=note: print w/ replies, xml ) Need Help??


in reply to Regex to add space after punctuation sign

The best I can come up with is

#! /usr/bin/perl use strict; while( <DATA> ) { s/(?<!\d), *|, *(?=\D)/, /g; print; } __DATA__ 1,2,a,b 1,a,2,b 1,a,b,2 a,1,2,b __produces__ 1,2, a, b 1, a, 2, b 1, a, b, 2 a, 1,2, b

But the use of alternation strikes me a bit as cheating. There is no doubt ABWTDI, but I can't see it for the moment.


Comment on Re: Regex to add space after punctuation sign
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (14)
As of 2014-10-20 10:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (75 votes), past polls