除去标记:

            string s = strSource;
            s = System.Text.RegularExpressions.Regex.Replace(s, @"(?<name1>\<.+?\>)(?<name3>.+?)(?<name2>\</.+?\>)", "${name3}", System.Text.RegularExpressions.RegexOptions.Compiled | System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            return s;

替换标记中的某个字符(本例演示的是字符标红)

使用时必须先给传入字符串加一个标记

                                string strValue = "<ddd>"+strIn+"</ddd>";

                                Regex re = new Regex(@"(?<name1>\<[^\>]+\>)(?<name3>[^\<]*?)(?<name4>"+strReplace+@")(?<name5>[^\>]*?)(?<name2>\</[^\<]+\>)", RegexOptions.IgnoreCase);
                                strValue = re.Replace(strValue, "${name1}${name3}<span style='color:red'>${name4}</span>${name5}${name2}");

 

以上是在做搜索时遇到的,效果不是很好,只能暂时凑合着用

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
  • 2021-05-28
  • 2021-12-16
  • 2022-02-10
  • 2021-09-10
猜你喜欢
  • 2021-07-12
  • 2022-01-29
  • 2021-10-06
  • 2021-12-24
  • 2021-10-14
  • 2021-06-07
相关资源
相似解决方案