匹配以“<tag1 attribute =”0“>”开头并以“”结尾的字符串的正则表达式是什么?</tag1>

时间:2012-07-18 22:25:33

标签: regex regex-greedy

匹配以<tag1 attribute="0">开头并以</tag>结尾的字符串的正则表达式是什么?

1 个答案:

答案 0 :(得分:0)

正则表达式:<tag1 attribute=”0“>.*?<\/tag>

Test code

using System;
using System.Text.RegularExpressions;

public class Test
{
  public static void Main()
  {
    string input = @"this is <tag1 attribute=""0""> and ends with </tag>, okay?";
    Console.WriteLine(input);
    Match match = Regex.Match(input, @"<tag1 attribute=""0"">.*?<\/tag>",
      RegexOptions.IgnoreCase);
    if (match.Success)
    {
      Console.WriteLine("Match!");
    }
  }
}