How to remove ↵ character from JS string
works fine.
If it works fine, then why bother? Your solution is totally acceptable.
but I want to know is there is any other way to remove these kind of unnecessary characters.
You could also use
"↵select * from eici limit 10".split("↵").join("")
Instead of using the literal character, you can use the codepoint.
Instead of "↵"
you can use "\u21b5"
.
To find the code, use '<character>'.charCodeAt(0).toString(16)
, and then use like \u<number>
.
Now, you can use it like this:
string.split("\u21b5").join(''); //split+join
string.replace(/\u21b5/g,''); //RegExp with unicode point
You can also try regex
as well,
"↵select * from eici limit 10".replace(/↵/g, "")