Namburi Manikanta Namburi Manikanta - 4 years ago 86
Javascript Question

RegEx to check first two characters must be "1 (numaric)-" in 9 letter word remaing should be alphanumaric

I tried coding in such way that code was not working

var redEx = /^1-[0-9a-zA-Z]{7}/;


Example: '1-5S6AW2R': in the string first letter should be numeric and
second character must be "-" and remain alpha-numeric.

Answer Source

It's regexObj.test(string) instead of string.test(regexObj).

See RegExp.prototype.test() for more information.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download