Javascript Regular Expressions Search Sub String
let myRegexp = /Java(Script)?/g; let myString = "Both Java and JavaScript share the same name, but are quite different."; myRegexp.exec(myString);//w w w .j a va 2s .co m console.log( myRegexp.lastIndex); // 9 myRegexp.exec(myString); console.log( myRegexp.lastIndex); // 24 myRegexp.exec(myString); console.log( myRegexp.lastIndex ); // 0