Archived
1
0
This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
SomeLab/15_7/Program.cs
2025-11-15 20:25:57 +08:00

24 lines
727 B
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Text.RegularExpressions;
namespace _15_7
{
internal class Program
{
static void Main(string[] args)
{
MatchCollection mc;
string[] result = new string[20]; int[] matchposition = new int[20];
Regex r = new Regex("abc");
mc = r.Matches("123abc4abcd");
Console.WriteLine("源字符串123abc4abcd");
Console.WriteLine("匹配字符串abc");
for (int i = 0; i < mc.Count; i++)
{
result[i] = mc[i].Value;
matchposition[i] = mc[i].Index;
Console.WriteLine("索引位置{0};结果{1}", mc[i].Index, mc[i].Value);
}
}
}
}