Home >Web Front-end >JS Tutorial >Rookie javascript basic information compilation 3 regular rules_basic knowledge
1.js regular expression (RegExp object)
RegExp object has 3 methods: test(), exec() and compile().
①test() method
//The test() method retrieves the specified value in the string. The return value is true or false.
var patt1=new RegExp("e");
document.write(patt1.test("The best things in life are free"));
②exec() method
//exec () method retrieves a specified value in a string. The return value is the found value. If no match is found, null is returned.
var patt1=new RegExp("e");
document.write(patt1.exec("The best things in life are free"));
To be continued.