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

New Post: HtmlAgilitypack on strings C#

$
0
0

Here is my solution would have to use a string loop through the regex to do the replace as couldn't think of a way to do multiple spaces based on the match.

string html = "erwerw<p style=\"padding-left: 30px;\">ijkk</p>rwwr<p style=\"padding-left: 40px;\">ijkk</p>";
mc = Regex.Matches(html, "(?<complete><p[^>]*style=[^>]*\"[^>]*padding-left:\\s?(?<number>[0-9]*)px[^>]*>(?<text>[^<]*)</p>)");
foreach (Match match in mc)
{
if (match.Groups.Count > 0)
   {
      html = html.Replace(match.Groups["complete"].Value, string.Format("{0}{1}", newstring(' ',Convert.ToInt32(match.Groups["number"].Value)), match.Groups["text"].Value));
   }
}
Hope this helps

Viewing all articles
Browse latest Browse all 655

Trending Articles



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