class Program
{
static void Main(string[] args)
{
//反向引用
//在表达式内部使用之前捕获分组匹配的文本
string str = "aa";
string reg = @"([a-z])\1";//这里的\1就表示,引用第一个()中匹配的文本内容
bool res = Regex.IsMatch(str, reg);
Console.WriteLine(res.ToString());

string str2 = "<a>dd</a>";
string reg2 = @"<([^>]+)>[/d/D]*?</\1>";//这里的\1就表示,引用第一个()中匹配的文本内容
bool res2 = Regex.IsMatch(str2, reg2);
Console.WriteLine(res2.ToString());

Console.ReadKey();
}
}

相关文章:

  • 2021-05-31
  • 2021-06-29
  • 2022-12-23
  • 2021-07-11
  • 2021-09-07
  • 2021-05-21
猜你喜欢
  • 2022-02-07
  • 2022-02-23
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2021-07-29
  • 2021-05-20
相关资源
相似解决方案