Another option you can do here is Negative Lookahead .
Find: \s+(?![^,]) Replace:
Regular expression:
\s+ whitespace (\n, \r, \t, \f, and " ") (1 or more times) (?! look ahead to see if there is not: [^,] any character except: ',' ) end of look-ahead
Or look for word characters.
Find: \s+(?!\w) Replace:
Regular expression:
\s+ whitespace (\n, \r, \t, \f, and " ") (1 or more times) (?! look ahead to see if there is not: \w word characters (az, AZ, 0-9, _) ) end of look-ahead
You can also use Positive Lookahead to see if there are characters other than words.
Find: \s+(?=\W) Replace:
source share