返回到:JavaScript对象:JavaScript RegExp 对象
定义和用法
global 属性用于返回正则表达式是否具有 “g” 。
如果 g 标志被设置,则该属性为 true,否则为 false。
语法
RegExpObject.global所有主要浏览器都支持 global 属性。
实例
查看正则表达式是否具有标志 g:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Web176教程(Web176.com)</title>
</head>
<body>
<script>
var str="Visit web176!";
var patt1=/web/g;
if(patt1.global)
{
document.write("g 模式有设置!");
}
else
{
document.write("g 模式没有设置!");
}
</script>
</body>
</html>作者:terry,如若转载,请注明出处:https://www.web176.com/javascriptbook/jsarrtips/2945.html
支付宝
微信