문제 설명
화살표 문자가 포함된 문자열 분할 (Split a string containing arrow characters)
저는 Github API를 사용하여 페이지에 댓글을 로드하고 있으며 이메일에서 온 댓글을 로드할 때 아래와 같이 화살표 형식으로 지정됩니다.
'Comment↵↵On 13 November 2015 at 16:50...'
두 번째 부분을 제거하고 싶습니다. 주석을 얻었지만 자바스크립트 분할 방법을 사용하여 이 작업을 수행할 수 없는 것 같습니다. 다음을 시도했습니다.
comment.split('↲');
comment.split('↵');
다음 HTML 코드에 따라: http://character‑code.com/arrows‑html‑codes.php
또한 Regex를 사용해 보았습니다. :
comment.split(/&[^;]*;/);
어느 쪽도 작동하지 않는 것 같습니다.
이와 같은 화살표로 문자열을 분할하는 방법을 아는 사람이 있습니까?
감사합니다.
참조 솔루션
방법 1:
It might be the new line characters try this.
comment = comment.replace(/(?:\r\n|\r|\n)/g, '');
(by Emile Paffard‑Wray、Azad)