in reply to Regex to add space after punctuation sign

No alternation, no /e, just soft and pink.
s/(?!\d[.,]\d)(.[^\w\s])(?!\s)/$1 /g;
Update
Just noticed how similar this is to ysth's solution, but his use of lookahead/lookbehind is really advanced.
...and...
Had removed the dot from the group. Need that. (Thanks, dda.)

The PerlMonk tr/// Advocate

Replies are listed 'Best First'.
Re: Re: Regex to add space after punctuation sign
by dda (Friar) on Jan 10, 2004 at 20:34 UTC
    Hmm.. Just tried:
    $_ = "1.2.a.b"; s/(?!\d[.,]\d)([^\w\s])(?!\s)/$1 /g; print;
    Prints "1. 2. a. b"

    --dda