using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace RegexDemo
{
class Program
{
static void Main(string[] args)
{
//string str = "2345 2346666";
//string pattern = @"(?<aa>23(?:45|46))";
string str = "student disposition close open successs support";
string pattern = @"(?<aa>(\bs\S*))\D*(?<bb>(close))";
string pattern2 = @"\b\S*\b";
string pattern3 = @"(.)\1";//匹配2个相同的字符
Regex va = new Regex(pattern3);
MatchCollection mm= va.Matches(str);
foreach (Match theMatch in mm)
{
//Console.WriteLine(theMatch.Groups["aa"]);
//Console.WriteLine(theMatch.Groups["bb"]);
Console.WriteLine(theMatch.Value);
}
Console.ReadKey();
}
}
}