global是正则表达式对象的只读布尔属性。它指定是否一个特定的正则表达式进行全局匹配。否则它使用“g”属性创建。
语法
regexpobject.global
下面是参数的详细信息:
返回值:
例子:
<html> <head> <title>javascript regexp global property</title> </head> <body> <script type="text/javascript"> var re = new regexp( "string" ); if ( re.global ){ document.write("test1 - global property is set"); }else{ document.write("test1 - global property is not set"); } re = new regexp( "string", "g" ); if ( re.global ){ document.write("<br />test2 - global property is set"); }else{ document.write("<br />test2 - global property is not set"); } </script> </body> </html>
这将产生以下结果:
test1 - global property is not set test2 - global property is set
如对本文有疑问, 点击进行留言回复!!
2020-07-21 html5如何监听veido的全屏 + css的字体间距 + JS的window.open() + 软技能svn与git
html+css+js适合前端小白的实战全解(超详细)——2048小游戏(二)
在使用@angular/cli创建的angular项目上添加postcss等一系列移动端自适应插件
网友评论