I have a textarea and I’m using jQuery to delete all tabs, newlines, multi spaces etc with a single space whenever the text area is blurred.
However, when I use the following:
str.replace(/\s/g, ' ')
…it deletes all tabs and newlines but not the multi spaces.
When I try:
str.replace(/[ \s], ' ')
…the same thing happens.
When I try:
str.replace(/[(?= +)\s], ' ')
…it won’t escape my parentheses, etc.
Anyone know the correct syntax for what I’m trying to do?
Thanks.
http://jsfiddle.net/KrqDH/