The users of my web site don’t know where to put spaces around punctuation symbols. For example, after a period, comma or a semicolon there should be a whitespace but not after decimals or thousands-separators in numbers.
Does anyone have handy a regular expression that cleans up the text in this way?
Could you please modify it so that it deletes any whitespaces before the punctuation mark if they exist? I have to admit I’m lost when it comes to regular expressions and your function looks even stranger, with no forward slashes for delimiting patterns and sprintf() which I’ve never used. I promise I’ll get a good regex book.