测试C# 正则表达式
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
/*C# 正则表达式 测试
* [email protected]
* Createtime:2008-11-17 *
*
*/
namespace RegexTest
{
class Program
{
static void Main(string[] args)
{
string strPattern = @"/bnn";
//MatchCollection mathcol = Regex.Matches("bnnbnbnbbnn",strPattern);
//foreach (Match match in mathcol)
//{
// Console.WriteLine(match.Value);
//}
MatchCollection matchs = Regex.Matches("nnb nna nnc nnd nne nnf nng nnh", strPattern, RegexOptions.IgnoreCase);
Console.WriteLine(""+Regex.IsMatch("nnb nna nnc nnd nne nnf nng nnh",strPattern));
foreach(Match match in matchs)
{
foreach (Group group in match.Groups)
{
foreach (Capture cap in group.Captures)
{
Console.WriteLine(cap.Index + "," + cap.Length + "," + cap.ToString() + "," + cap.Value);
}
}
}
Console.Read();
}
}
}
相关类结构图: