//参数中的 g 表示全部匹配,i表示忽略大小写
//str='toaction=t23rue';
//str='toaction=t23rue';
str='toactioN=True';
str=str.replace(/toaction=[\w]+/gi,'toaction=false');
alert(str);
举一个使用的下面一个例子:
function addQueryString()
{
// thickbox query string
var tbString = $_('compStart').alt;
if($_('toaction').checked) tbString = tbString.replace(/toaction=[\w]+/gi,'toaction=true');
else tbString = tbString.replace(/toaction=[\w]+/gi,'toaction=false');
if($_('towinner').checked) tbString = tbString.replace(/towinner=[\w]+/gi,'towinner=true');
else tbString = tbString.replace(/towinner=[\w]+/gi,'towinner=false');
$_('compStart').alt=tbString;
}
没有评论:
发表评论