I am getting myArray as null. Can anyone help me?
myRe = new RegExp ("[A-Z]+(\\d+)");
myArray = myRe.exec("book1");
alert(myArray.length);
I am getting myArray as null. Can anyone help me?
myRe = new RegExp ("[A-Z]+(\\d+)");
myArray = myRe.exec("book1");
alert(myArray.length);
Your regular expression is case sensitive; try:
myRe = new RegExp ("[A-Za-z]+(\\d+)");
or:
myRe = new RegExp ("[A-Z]+(\\d+)", "i");
It's because you use [A-Z] which is for uppercase.
Use this instead:
pattern = /[a-z](\d+)/i;
myArray = pattern.exec("BOOK1");
alert(myArray.length);