0

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! :)

1 Answer 1

3

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}, M being the minimum and N the maximum.

Sign up to request clarification or add additional context in comments.

3 Comments

umm, what do you mean escape? ***\ ? Kindly show me a code please. Thanks!
\*\*\*\*. Or \*{4}. What are you trying to accomplish?
I'm tyring to search a string if it has a ****

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.