Remove all br from string javascript
I have a string that i would like to remove all occurrences of Show I tried this and it did not work.
However this worked but only for the first
How would I get it to work for all Edit: this is the string...
My apologies for
being a little misleading with the asked Nov 15, 2010 at 12:23
user357034user357034 10.4k19 gold badges56 silver badges72 bronze badges 1 Using regular expression you can use this pattern
That pattern matches
etc... answered Nov 15, 2010 at 13:37
DavideDMDavideDM 1,43515 silver badges18 bronze badges 1 Looks like your string is encoded so use
note the demo at http://www.jsfiddle.net/gaby/VDxHx/ answered Nov 15, 2010 at 12:33
Gabriele PetrioliGabriele Petrioli 185k34 gold badges254 silver badges306 bronze badges 1 You could use the
Of course you should be aware that this won't replace See an example of this working on ideone. UPDATE: Now that you've provided an example with your input here's a working regex you might use to replace:
answered Nov 15, 2010 at 12:25
Darin DimitrovDarin Dimitrov 1.0m267 gold badges3252 silver badges2911 bronze badges 9 I've not tested it but you could try something like this
answered Nov 15, 2010 at 12:29
m4rcm4rc 2,8622 gold badges21 silver badges29 bronze badges Remove all Line Breaks from a String in JavaScript #Use the
We passed a regular expression to the String.replace method. The forward slashes Let's first cover the The The The square brackets We want to replace both For example, Windows
uses The second parameter we passed to the
For our purposes, we replace each occurrence of a line break with an empty string. The Further Reading #
How do I remove all line breaks from a string?Use the String. replace() method to remove all line breaks from a string, e.g. str. replace(/[\r\n]/gm, ''); . The replace() method will remove all line breaks from the string by replacing them with an empty string.
Does trim remove line breaks?trim method removes any line breaks from the start and end of a string. It handles all line terminator characters (LF, CR, etc). The method also removes any leading or trailing spaces or tabs.
What is regex GM?In the expression /Regex/gm. The "m" stands for multi-line matching. In the expression: m/Regex/g. The "m" stands for "match" as opposed to a substitution, which looks like this: s/Regex/replacement/g. Because matching (vs.
|