C#限定符正則表達式
限定符指定的前一個元素(其可以是一個字符,一個組,或在字符類)中必須存在的匹配來發生輸入字符串有多少實例。
限定符 | 描述 | 模式 | 匹配 |
---|---|---|---|
* | 匹配先前元素零次或多次 | d*.d | ".0", "19.9", "219.9" |
+ | 匹配前一個元素的一個或更多次 | "be+" | "bee" in "been", "be" in "bent" |
? | 匹配先前元素零次或一次 | "rai?n" | "ran", "rain" |
{ n } | 恰好n次匹配前麵的元素 | ",d{3}" | ",043" in "1,043.6", ",876", ",543", and ",210" in "9,876,543,210" |
{ n ,} | 至少匹配一個元素n次 | "d{2,}" | "166", "29", "1930" |
{ n , m } | 匹配前麵的元素至少n次,但不超過m次。 | "d{3,5}" | "166", "17668" "19302" in "193024" |
*? | 匹配先前元素零次或多次,但儘可能作為幾次 | d*?.d | ".0", "19.9", "219.9" |
+? | 匹配前一個元素的一個或更多次,但儘可能作為幾次 | "be+?" | "be" in "been", "be" in "bent" |
?? | 匹配先前元素零個或一次,但儘可能幾次。 | "rai??n" | "ran", "rain" |
{ n }? | 恰好匹配前麵的元素n次 | ",d{3}?" | ",043" in "1,043.6", ",876", ",543", and ",210" in "9,876,543,210" |
{ n ,}? | 匹配前麵的元素至少n次,但越少幾次越好 | "d{2,}?" | "166", "29", "1930" |
{ n , m }? | 匹配n和m次之間,但幾次儘可能作為前一個元素 | "d{3,5}?" | "166", "17668" "193", "024" in "193024" |