RegExp构造函数属性 3

2017-06-15 19:08:00
admin
原创
525
<!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 = /(..)or(.)/g;
              
        if (pattern.test(text)){
            alert(RegExp.$1);       //sh
            alert(RegExp.$2);       //t
        }

    </script>
</head>
<body>

</body>
</html>
  • QQ讨论群
  • 关注微信
    • 欢迎咨询
    • 欢迎加入QQ群 16506021
  • 公众号:源宝网络