in reply to Removing unwanted characters and extra spaces from string.
The {2,} on \s won't work inside a []. Try this instead: s/(?:[^a-zA-Z0-9,_\s]+|[\s_]\K\s+)//g (Note: The link needs a fairly modern browser to work.)
Update: I should mention that this regex also removes the space between Description_ and Test because that's what you showed in your expected output, but hippo is right to ask whether this is what you want. As always with regexes, please provide as many example inputs and outputs as possible, along with a clear spec!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Removing unwanted characters and extra spaces from string.
by Anonymous Monk on Sep 27, 2018 at 15:00 UTC |