1、鼠标点击打开HBuilder软件,如图所示:
2、点击新建一个Web项目,如图所示:
3、输入项目名,然后点击完成,如图所示:
4、然后键入如下代码,<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title>如何在js中的带大括号的正则表达式</title> </head> <script type="text/javascript">var str="123{xxxx}456[我的]789123[你的]456(1389090)789";var regex1 = /\((.+?)\)/g; // () 小括号var regex2 = /\[(.+?)\]/g; // [] 中括号var regex3 = /\{(.+?)\}/g; // {} 花括号,大括号// 输出是一个数组alert(str.match(regex1));alert(str.match(regex2));alert(str.match(regex3));</script> <body> 如何在js中的带大括号的正则表达式 </body></html>如图所示:有小、中、大括号的正则表达式
5、然后点击运行-->浏览器运行,如图所示:
6、运行结果如图所示:小、中、大括号的正则表达式