在正则表达式的末尾'/'之外有字符?

[英]Having characters outside the end '/' of a regex?


var myRe = /d(b+)d/g;  
var myArray = myRe.exec("cdbbdbsbz");  

what does that g after the regex do?

正则表达式之后的那个g是什么?

3 个解决方案

#1


2  

It means 'apply regex globally' (or repeatedly) to the target. It affects replace operations rather than the match expression per se.

这意味着“全局应用正则表达式”(或重复)到目标。它会影响替换操作,而不是匹配表达式本身。

#2


1  

The "g" enables global matching and is useful primarily when doing a replace() operation. References:

“g”启用全局匹配,主要用于执行replace()操作。参考文献:

#3


0  

In Perl, /g tells the regex engine to search the entire string for occurences, and not stop at the first occurence.

在Perl中,/ g告诉正则表达式引擎搜索整个字符串是否出现,而不是在第一次出现时停止。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2010/12/27/190aff8abfcf15ef67c5e212fb947af2.html



 
  © 2014-2022 ITdaan.com 联系我们: