怎么换掉一个变量?
re = /\./g;
namestr = namestr .replace(re, " ");
======================
上面是将字符串中的.去掉,就是换成空,但是这个点是一个变量怎么写?
re = /\+value+/g; 怎么写都不对,
------解决方案--------------------namestr= "abc "
function fun(a){
re = new RegExp(a, "gi ")
namestr1 = namestr .replace(re, " ");
alert(namestr1)
}
fun( "a ")
fun( "b ")