在正則表達式的末尾'/'之外有字符?

[英]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 联系我们: