str = "(" + str.replace(/[^\d.+-*\/()]+/g,"") + ")"; 是什么意思?

来源:学生作业帮助网 编辑:六六作业网 时间:2024/05/05 11:44:12
str="("+str.replace(/[^\d.+-*\/()]+/g,"")+")";是什么意思?str="("+str.replace(/[^\d.+-*\/()]+/g,"")+")";是什

str = "(" + str.replace(/[^\d.+-*\/()]+/g,"") + ")"; 是什么意思?
str = "(" + str.replace(/[^\d.+-*\/()]+/g,"") + ")"; 是什么意思?

str = "(" + str.replace(/[^\d.+-*\/()]+/g,"") + ")"; 是什么意思?
str = "(" + str.replace(/[^\d.+-*\/()]+/g,"") + ")" ;
我想是将str 中的不是数字及 + - * / () 及 小数点的字符去掉.然后在套上括号.
但他的正则好像有点问题,稍微改下
var str="asd323+f4345*234.3a";
alert( str.replace(/[^\d\+\.\-\*\/()]+/g,""));
输出 323+4345*234.3