in reply to Re: regex to remove space
in thread regex to remove space

I think there's an easier way:
s/(?<=\S) +/,/g;
That replaces one or more contiguous spaces with comma throughout the string, but only if there's a non-space character preceding (positive look-behind).

Replies are listed 'Best First'.
Re^3: regex to remove space
by perlUser345 (Acolyte) on Dec 16, 2015 at 17:20 UTC

    You sir deserve more upvotes! Lol, thank you so much!