真的,问题很简单,为什么这不起作用?以及如何以清白的方式实现我想要的?
var toClean = "Test & &";
var result = toClean.replace(/([&"'<>](?!quot;|lt;|gt;|apos;|amp;))/g,_.escape("$1"));
console.log(result); // prints => "Test & &"
// what i expect is => "Test & &"
请记住,这是有效的:
var toClean = "Test & &";
var result = toClean.replace(/([&"'<>](?!quot;|lt;|gt;|apos;|amp;))/g,
_.toUpper("a"));
console.log(result); // prints => "Test & A"