Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript: replace ↵ from string [duplicate]

Tags:

javascript

I have a super annoying raw data which is littered with and there's no way I can str.replace('↵','') is there? I tried it and didn't work, I couldn't find anything on this because when I search for it doesn't show up the ascii code.

like image 281
user299709 Avatar asked Mar 04 '16 23:03

user299709


People also ask

How do you replace every instance of a character in a string?

To replace all occurrences of a substring in a string by a new one, you can use the replace() or replaceAll() method: replace() : turn the substring into a regular expression and use the g flag.

How do you replace all occurrences of a character in a string in TypeScript?

To replace all occurrences of a string in TypeScript, use the replace() method, passing it a regular expression with the g (global search) flag. For example, str. replace(/old/g, 'new') returns a new string where all occurrences of old are replaced with new .

What can I use instead of replaceAll in JavaScript?

To make the method replace() replace all occurrences of the pattern you have to enable the global flag on the regular expression: Append g after at the end of regular expression literal: /search/g. Or when using a regular expression constructor, add 'g' to the second argument: new RegExp('search', 'g')

What is replace () in JavaScript?

The replace() method searches a string for a value or a regular expression. The replace() method returns a new string with the value(s) replaced. The replace() method does not change the original string.


1 Answers

Use to replace all '\n'

str.replace(/\n/ig, '');
like image 64
Dmitriy Avatar answered Sep 22 '22 11:09

Dmitriy