Home >Web Front-end >HTML Tutorial >What is the role of the exec method in JavaScript RegExp?
The exec() method in JavaScript searches for a string with a pattern. If no match is found, NULL is returned, otherwise the text you searched for is returned.
You can try running the following code to learn how to use the exec() method in JavaScript regular expressions -
<html> <head> <title>JavaScript Regular Expressions</title> </head> <body> <script> var myStr = "Welcome to our website! Welcome to Tutorialspoint!"; var res = /t/.exec(myStr); document.write(res); </script> </body> </html>
The above is the detailed content of What is the role of the exec method in JavaScript RegExp?. For more information, please follow other related articles on the PHP Chinese website!