W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JavaScript 正则表达式</h1> <p>在字符串中搜索“w3School”,并显示匹配的位置:</p> <p id="demo"></p> <script> var str = "Visit W3School!"; var n = str.search(/w3School/i); document.getElementById("demo").innerHTML = n; </script> </body> </html>