纯正则替换排除图片

   protected void Button1_Click(object sender, EventArgs e)
        {
            string test2 = @"<img alt=""blogs"" src=""images / promo_clhs - shareholder-approval.jpg"">";
            string HTMLsource = @"<a href="""" tag=""Hello, approval happly day"">Hello, approval. happly day?</a>";
            string pattern = @"(?<!<[^>]*)approval(?<![^>]*<)";
            string output = Regex.Replace(HTMLsource, pattern, string.Format("<span class='hlt'>{0}</span>", "Test string"), RegexOptions.IgnoreCase);
            string pattern2 = @"(?<!<[^>]*)approval(?<![^>]*<)";
            string output2 = Regex.Replace(test2, pattern2, string.Format("<span class='hlt'>{0}</span>", "Test string"), RegexOptions.IgnoreCase);
            Response.Write(output + "  <br />");
            Response.Write(output2 + "  <br />");

        }
声明:本站资源绿色无后门无广告,可放心下载。如无特殊说明或标注,均为本站原创发布,转载请注明出处!