新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
C#正則表達(dá)式GroupCollection類(lèi)淺析
C#正則表達(dá)式GroupCollection類(lèi)是什么呢?C#正則表達(dá)式GroupCollection類(lèi)是如何使用的呢?下面讓我們來(lái)具體的內(nèi)容:

下面通過(guò)介紹 .NET 框架的正則表達(dá)式類(lèi),熟悉一下.NET框架下的正則表達(dá)式的使用方法。
C#正則表達(dá)式GroupCollection類(lèi)表示捕獲的組的集合
該集合為只讀的,并且沒(méi)有公共構(gòu)造函數(shù)。GroupCollection 的實(shí)例在 Match.Groups 屬性返回的集合中返回。下面的控制臺(tái)應(yīng)用程序查找并輸出由正則表達(dá)式捕獲的組的數(shù)目。
C#正則表達(dá)式GroupCollection類(lèi)實(shí)例應(yīng)用:
- using System;
- using System.Text.RegularExpressions;
- public class RegexTest
- {
- public static void RunTest()
- {
- Regex r = new Regex("(a(b))c");
- //定義組
- Match m = r.Match("abdabc");
- Console.WriteLine(
- "Number of groups found = " + m.Groups.Count);
- }
- public static void Main()
- {
- RunTest();
- }
- }
該示例產(chǎn)生下面的輸出:
- Number of groups found = 3
C#正則表達(dá)式GroupCollection類(lèi)的基本內(nèi)容就向你介紹到這里,希望對(duì)你了解和學(xué)習(xí)C#正則表達(dá)式GroupCollection類(lèi)有所幫助。
網(wǎng)站欄目:C#正則表達(dá)式GroupCollection類(lèi)淺析
網(wǎng)址分享:http://www.dlmjj.cn/article/coiggdg.html


咨詢(xún)
建站咨詢(xún)
