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" |