⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class1.cs

📁 C#开发教程 由浅入深 配有实例 是初学者的好帮手
💻 CS
字号:
using System;
using System.Text.RegularExpressions;

namespace Capturing
{
	class CapturingApp
	{
		[STAThread]
		static void Main(string[] args)
		{
			// define groups 'ing', 'in', 'n'
			Regex r = new Regex("(i(n))g");
			Match m = r.Match("Matching");
			GroupCollection gc = m.Groups;

			Console.WriteLine(
				"Found {0} Groups", gc.Count);

			for (int i = 0; i < gc.Count; i++)
			{
				Group g = gc[i];
				Console.WriteLine(
					"Found '{0}' at position {1}",
					g.Value, g.Index);
			}

			Console.WriteLine();
			for (int i = 0; i < gc.Count; i++) 
			{
				CaptureCollection cc = gc[i].Captures; 
				for (int j = 0; j < cc.Count; j++) 
				{
					Capture cap = cc[j];
					Console.WriteLine(
						"Found '{0}' at position {1}",
						cap.Value, cap.Index); 
				}
			}		
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -