W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<html> <body> <script type="text/javascript"> var str = "The rain in Spain stays mainly in the plain"; var patt1 = new RegExp("ain", "g"); for(i = 0; i < 4; i++) { patt1.test(str) document.write("ain found. index now at: " + patt1.lastIndex); document.write("<br />"); } </script> </body> </html>