Vue- remove ‘\n’ which get from database

blossom0417
2 min readOct 7, 2019

--

  1. replace 로 원하는 글자를 없앤다.
"[롯데상품권 교환권]\\n5,000원 ".replace('\\n', '')//값은 정확히 아래와 같이 나온다. 
[롯데상품권 교환권]5,000원

그러나 내가 받은 데이터는 string인데 위와같이 해보면 절대로 안된다.

이런식으로 \n이 자꾸 나온다. 왜지?

하루종일 검색. 1일을 이것에만 매달렸다. (다른일도 물론 함..)

드디어 1.5일째. 나왔다.

item.couponDisplayTitle.replace('\\\\n', '')

내 모든 능력을 동원한 폭풍 검색을 통해서.. \\\\n

허탈하다. 이게 아마 db에 따라서 달라지나보다.

\n 출력 하던가 \\n으로 출력하던가.

String str = //value read from DB
str = str.replaceAll("\\\\n", "\n");

#ref

https://stackoverflow.com/questions/17750438/behaviour-of-nnew-line-character-geting-from-database

--

--

No responses yet