• λ我爱Aspx >> Asp.Net >> 全面剖析C#正则表达式
  • 全面剖析C#正则表达式

  • :未知  Դ:internet  :2007-5-20 16:43:05  ؼ:c#
  • Match方法是在输入字符串中搜索正则表达式的匹配项,并Regex 类的 Match 方法返回 Match 对象,Match 类表示正则表达式匹配操作的结果。下面的例子演示Match方法的使用,并利用Match对象的Group属性返回Group对象:

    string text = @"public string testMatchObj string s string match ";

    string pat = @"(\w+)\s+(string)";

    // Compile the regular expression.

    Regex r = new Regex(pat, RegexOptions.IgnoreCase);

    // Match the regular expression pattern against a text string.

    Match m = r.Match(text);

    int matchCount = 0;

    while (m.Success)

    {

    Response.Write("Match"+ (++matchCount) + "<br>");

    for (int i = 1; i <= 2; i++)

    {

    Group g = m.Groups[i];

    Response.Write("Group"+i+"='" + g + "'" + "<br>");

    CaptureCollection cc = g.Captures;

    for (int j = 0; j < cc.Count; j++)

    {

    Ҷƪл˵?
  • һƪC#怎样才能实现窗体最小化到托盘呢?
    һƪ正则表达式语法