删除所有< br>从一个字符串 [英] remove all <br> from a string
本文介绍了删除所有< br>从一个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字符串,我想删除所有出现的< br>
I have a string that i would like to remove all occurrences of <br>
我试过这个并没有用。
productName = productName.replace("<br>"," ");
然而这只适用于第一个< br>
However this worked but only for the first <br>
productName = productName.replace("<br>"," ");
我如何让它适用于所有< br>
在字符串中。
How would I get it to work for all <br>
in the string.
编辑:这是字符串......
this is the string...
00-6189 Start Mech Switch& br& gt; 00-6189 Start Mech Switch& br& gt; 00-6189 Start Mech Switch& br& gt;
我对< br> $ c $有点误导我表示道歉c>因为它应该是
& lt; br& gt;
推荐答案
看起来您的字符串已编码,因此请使用
Looks like your string is encoded so use
productName = productName.replace(/<br>/g," ");
请注意正则表达式后的 g
全局,表示匹配所有出现次数。
note the g
after the regular expression which means globally, to match all occurrences.
演示 http://www.jsfiddle.net/gaby/VDxHx/
这篇关于删除所有< br>从一个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文