exec()
JavaScript中的方法搜索带有模式的字符串。如果找不到匹配项,则返回NULL,否则返回您搜索的文本。
您可以尝试运行以下代码,以了解如何使用exec()
JavaScript正则表达式中的方法-
<html> <head> <title>JavaScript Regular Expressions</title> </head> <body> <script> var myStr = "Welcome to our website! Welcome to Nhooo!"; var res = /t/.exec(myStr); document.write(res); </script> </body> </html>