Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 655

New Post: HtmlAgilitypack on strings C#

$
0
0
How about this. will require 2 passes..

result:
<b>For testing of </b><i>API </i>calls in <b>Incident API</b>.
string v = "<p style=\"margin: 0px 0px 12px 0px;text-align: left;text-indent: 0pt;padding: 0px 0px 0px 0px;\"><span style=\"font-family: 'Verdana';font-style: Normal;font-weight: bold;font-size: 16px;color: #000000;\">For testing of </span><span style=\"font-family: Verdana; font-weight: normal; font-size: 16px; color: rgb(0, 0, 0);\"><i>API </i></span><span style=\"font-family: 'Verdana';font-style: Normal;font-eight: normal;font-size: 16px;color: #000000;\">calls in </span><span style=\"font-family: 'Verdana';font-style: Normal;font-weight: bold;font-size: 16px;color: #000000;\">Incident API</span><span style=\"font-amily: 'Verdana';font-style: Normal;font-weight: normal;font-size: 16px;color: #000000;\">.</span></p>";

Regex r = new Regex(@"<span [^>]*(?:font-weight:\s?bold)[^>]*>(?<boldtext>[^<]*)</span>");
string t = r.Replace(v,"<b>$1</b>");


Regex p = new Regex("<((?!b)(?!i))[^/>]*>|</((?!b)(?!i))[^>]*>");
string q = p.Replace(t, "");

Viewing all articles
Browse latest Browse all 655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>