我正在使用Javascript上的RegEx,这里是我卡住的地方。如何替换两个符号之间所有出现的字符串?
我有一个简单的字符串像
<html><body><span style=3D"font-family:Verdana; color:#000; font-size:10pt;=
"><div><font face=3D"verdana, geneva" size=3D"2">http://72.55.146.142:8880/=
order003.png.zip,120</body></html>
所有我需要做的是写javascript可以与“<”和“>”符号替换所有字符串。
我写了这样的事情 -
var strReplaceAll = Body;
var intIndexOfMatch = strReplaceAll.indexOf("<");
while (intIndexOfMatch != -1){
strReplaceAll = strReplaceAll.replace(/<.*>/,'')
intIndexOfMatch = strReplaceAll.indexOf("<");
}
但问题是,如果体内含有 -
test<abc>test2<adg>
它会给我 -
test
仅或者如果体内含有像 -
<html>test<abc>test2<adg>
它会给我什么,请让我知道我可以GET-
testtest2
为最终输出。
[''Java'!='JavaScript'](http://stackoverflow.com/a/245069/1393766)。无论如何,你可能应该阅读贪婪和不情愿的量词。 – Pshemo 2014-09-01 13:16:10
使用HTML解析器。 – SLaks 2014-09-01 13:16:42
是简单的字符串包含换行符? – 2014-09-01 13:16:51