Py学习  »  MetalGodwin  »  全部回复
回复总数  1
13 年前
回复了 MetalGodwin 创建的主题 » regex使用验证器传递变量值并验证jquery[duplicate]
String.prototype.replaceAll = function(a, b) {
    return this.replace(new RegExp(a.replace(/([.?*+^$[\]\\(){}|-])/ig, "\\$1"), 'ig'), b)
}

像这样测试:

var whatever = 'Some [b]random[/b] text in a [b]sentence.[/b]'

console.log(whatever.replaceAll("[", "<").replaceAll("]", ">"))