RegExp构造函数属性 2

2017-06-15 19:06:00
admin
原创
323
<!DOCTYPE html>
<html>
<head>
    <title>RegExp Constructor Properties Example 2</title>
    <script type="text/javascript">
    
        var text = "this has been a short summer";
        var pattern = /(.)hort/g;
        
        /*
         * Note: Opera doesn't support short property names.
         * Internet Explorer doesn't support multiline.
         */        
        if (pattern.test(text)){
            alert(RegExp.$_);               //this has been a short summer
            alert(RegExp["$`"]);            //this has been a            
            alert(RegExp["$'"]);            // summer
            alert(RegExp["$&"]);            //short
            alert(RegExp["$+"]);            //s
            alert(RegExp["$*"]);            //false
        }

    </script>
</head>
<body>

</body>
</html>
文章分类
联系我们
电话: 18902328227
Email: 2689701946@qq.com
QQ: 2689701946
微信: 18902328227
地址: 广州番禺区繁华路
  • 在线客服
  • 关注微信
  • 联系电话
    • 欢迎咨询
    • 欢迎加入QQ群 303257430
  • 公众号:源宝网络
    • 联系电话及微信号 18902328227