说明
compile() 既可以改变检索模式,也可以添加或删除第二个参数
示例
<html> <head> <script type="text/javascript"> var patt1=new RegExp("e"); document.write(patt1.test("The best things in life are free")); patt1.compile("d"); document.write(patt1.test("The best things in life are free")); </script> </head> <body> </body> </html>
转载于:https://blog.51cto.com/suyanzhu/1902366