可能重复:
regular expression gives different output in FF and IE
我使用以下代码
function get_text(el) {
ret = "";
var length = el.childNodes.length;
for (var i = 0; i < length; i++) {
var node = el.childNodes[i];
if (node.nodeType != 8) {
ret += node.nodeType != 1 ? node.nodeValue : get_text(node);
}
}
return ret;
}
var queuediv = document.getElementById('MSO_ContentTable');
var total = get_text(queuediv);
countTotal = total.split(/\s+/).length;
alert(countTotal);div包含以下内容:-
You can get started fdfd erfd dsff代码给我输出:- 26注:- Chrome和Fx输出7,IE输出26。我认为问题在于正则表达式。我认为这个正则表达式在IE中不起作用
发布于 2011-06-23 06:48:55
正则表达式实际上并不标准化,一些工具确实使用+而不是+来表示贪婪的量词版本。您可以在IE中尝试这一点,看看结果是什么,然后有条件代码使其在IE中工作(想象一下)。
https://stackoverflow.com/questions/6449969
复制相似问题