Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
110
rated 0 times [  117] [ 7]  / answers: 1 / hits: 24666  / 14 Years ago, mon, november 15, 2010, 12:00:00

I have a string that i would like to remove all occurrences of <br>



I tried this and it did not work.



    productName = productName.replace(<br>, );


However this worked but only for the first <br>



    productName = productName.replace(&lt;br&gt;, );


How would I get it to work for all <br> in the string.



Edit: this is the string...



00-6189 Start Mech Switch&lt;br&gt;00-6189 Start Mech Switch&lt;br&gt;00-6189 Start Mech Switch&lt;br&gt;



My apologies for being a little misleading with the <br> as it should have been &lt;br&gt;


More From » regex

 Answers
2

Looks like your string is encoded so use



productName = productName.replace(/&lt;br&gt;/g, );


note the g after the regular expression which means globally, to match all occurrences.



demo at http://www.jsfiddle.net/gaby/VDxHx/


[#94958] Friday, November 12, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
christianu

Total Points: 481
Total Questions: 124
Total Answers: 99

Location: Trinidad and Tobago
Member since Thu, Dec 1, 2022
2 Years ago
christianu questions
;