此方法用於當匹配針對正則表達式的字符串來檢索匹配。
語法
string.match( param )
下面是參數的詳細信息:
返回值:
例子:
<html> <head> <title>JavaScript String match() Method</title> </head> <body> <script type="text/javascript"> var str = "For more information, see Chapter 3.4.5.1"; var re = /(chapter \d+(\.\d)*)/i; var found = str.match( re ); document.write(found ); </script> </body> </html>