1.组名   () 这样的用索引 \1,(?<name>) \<name>来引用

2.替换 $\1,${name}

c#正则简单总结(符号操作)

Regex.Replace(userInputString,"(Mr|Mrs)[a-z]*","$1 X");

Regex.Replace(userInputString,"(?<name>Mr|Mrs)[a-z]*","${name} X");

(?(exp)yes|no)

(?(name)yes|no) name的组

(?i:[a-z]) (?-i:[a-z])。

如果想删除一个项,只须在字母前加-

替换为$,位置也能替换

string test = "one test <123>, another test <321>";

Regex reg = new Regex(@"(?<=<)(?=\d+>)");

string result = reg.Replace(test, "$");

richTextBox2.Text = result;

相关文章:

  • 2021-06-25
  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2021-10-25
猜你喜欢
  • 2021-11-01
  • 2022-12-23
  • 2021-11-21
  • 2021-07-19
  • 2022-02-22
  • 2021-04-23
相关资源
相似解决方案