|Think about Loose Coupling|
Regex to add space after punctuation signby dda (Friar)
|on Jan 08, 2004 at 08:09 UTC||Need Help??|
dda has asked for the
wisdom of the Perl Monks concerning the following question:
I need to add a (missing) single space after each punctuation sign in a string, but only if it is not a dot or comma inside a number. For example, "1,2,a,b" should be changed to "1,2, a, b". Also if there is already a space after punctuation sign, it should not be duplicated.
Right now I have this simple one for comma replacement:
But it spoils my numbers. Can you help? Is there a way to do it with one regular expression?