A "quantifier" is a regular expression operator like *
or +
. The variable "d" in the above code probably contains something that's being interpreted as "code" to the regular expression parser, and it's invalid. You're right that it needs to be appropriately escaped. It's a problem very similar to the problem of escaping text that's being included in HTML markup, but distinct because the syntax in question is completely different (that is, regular expression syntax vs. HTML syntax).
There are a lot of special characters in regular expression syntax, obviously, so it'll take a pretty gnarly regex to do that. Here's a possible way to do such a thing:
var quoted = unquoted.replace(/([*+.?|\[]{}()])/g, '\$1');
That might not get all of them; I'd look around for code that's more definitely tested than something a dope like me just made up :-)
Since that code you posted looks like it may come from some library, you may want to check the stack trace from the IE debugger to find out where the problem starts.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…