본문 바로가기

JQuery-js-css

javascript 개행, 공백제거 replace

왼쪽 공백

str = str.replace(/\s+/, "");

 

오른쪽 공백
str = str.replace(/\s+$/g, ""); 

 

줄바꿈
str = str.replace(/\n/g, "");

 

엔터
str = str.replace(/\r/g, "");