js 正则表达式 /g 火狐下bug 正则表达式IEFirefox.net
程序员文章站
2022-06-11 10:21:40
...
<html>
<body>
<script type="text/javascript">
function isNumeric(strValue)
{
return /^\d*$/g.test(strValue);
}
function isNumeric1(strValue)
{
return /^\d*$/.test(strValue);
}
strValue = '1000'
document.writeln(isNumeric(strValue)); // true
document.writeln(isNumeric(strValue)); // firefox: false; IE:true
document.writeln('<br/>')
document.writeln(isNumeric1(strValue)); // true
document.writeln(isNumeric1(strValue)); // true
document.writeln('<br/>')
document.writeln(/^\d*$/g.test(strValue)); // true
document.writeln(/^\d*$/g.test(strValue));// true
</script>
</body>
</html>
原因分析见:http://www.jb51.net/article/18334.htm
<body>
<script type="text/javascript">
function isNumeric(strValue)
{
return /^\d*$/g.test(strValue);
}
function isNumeric1(strValue)
{
return /^\d*$/.test(strValue);
}
strValue = '1000'
document.writeln(isNumeric(strValue)); // true
document.writeln(isNumeric(strValue)); // firefox: false; IE:true
document.writeln('<br/>')
document.writeln(isNumeric1(strValue)); // true
document.writeln(isNumeric1(strValue)); // true
document.writeln('<br/>')
document.writeln(/^\d*$/g.test(strValue)); // true
document.writeln(/^\d*$/g.test(strValue));// true
</script>
</body>
</html>
原因分析见:http://www.jb51.net/article/18334.htm
上一篇: Python中表示字符串的几种方法介绍