Walter Nuñez Walter Nuñez - 4 months ago 22
jQuery Question

jquery remove all spaces and line break before any character character

hello friend i am cleaning some response from server becouse i dont have time to search all php files, space and line break in output, from buffer php...

in a response of ajax i get a paragraph of text, and i need remove all space and line break before anyone character and respect all: space and line break.

Example:

response = response.replace(/\s+/g, '');


this not respect Line Break or space on paragraph from response

Answer

Solved with this Update. regex

response = response.replace(/^\s+|\s+$/g,'');