Home >Web Front-end >JS Tutorial >Rookie javascript basic information compilation 3 regular rules_basic knowledge

Rookie javascript basic information compilation 3 regular rules_basic knowledge

WBOY
WBOYOriginal
2016-05-16 18:14:291167browse

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn