I’m using JavaScript’s .search() function and I have this code:
var temp_cc_number = "4111 1111 1111 1111";
var checker = "****";
alert(temp_cc_number.search(checker));
I’m getting this error:
"Invalid quantifier"
What do you think this is? Any help would be greatly appreciated and rewarded!
Thanks! 🙂
The
*is a zero or more quantifier, therefore if you’re trying to match literal*you need to escape it with the\. Or maybe a slightly better way:search(/\*{4}/). The{4}denotes a match count, in this case it matches the\*4 times. You can also specify minimum and maximum ranges{M:N},Mbeing the minimum andNthe maximum.