The method of three RegExp object

Original link: http://www.cnblogs.com/jf-67/p/6476967.html

 

  RegExp object has three methods: test (), exec () and compile ().

 

  test( )

  The method of retrieving the specified value string test (). The return value is true or false.

  example:

  

  Because of the letter "a" in the string, the output of the code will be: true

 

  exec( )

  The method of retrieving the specified value string exec (). The return value is the value to be found. If no match is found, null is returned

  

  Because of the letter "a" in the string, the output of the code would be: a

 

  compile()

  compile () method is used to change RegExp.

  compile () retrieval mode may be changed, or may be added to remove the second parameter.

  

  Because the presence of "a", but not "x", the output of the code string are: true false

Reproduced in: https: //www.cnblogs.com/jf-67/p/6476967.html

Guess you like

Origin blog.csdn.net/weixin_30721899/article/details/94783258
Recommended