运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h2>JavaScript Regular Expressions</h2> <p>The exec() method tests for a match in a string:</p> <p id="demo"></p> <script> let text = "Hello world!"; // look for "Hello" let result1 = /Hello/.exec(text); // look for "W3Schools" let result2 = /W3Schools/.exec(text); document.getElementById("demo").innerHTML = result1 + "<br>" + result2; </script> </body> </html>