본문 바로가기 메뉴 바로가기

대표이미지

[javascript] 개행, 공백 제거

2021. 6. 22.

왼쪽 공백

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

 

오른쪽 공백

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

 

줄바꿈

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

 

엔터

str = str.replace(/\r/g, "");
댓글 갯수
TOP