Glory Jain Glory Jain - 1 year ago 83
C# Question

Unable to build a regex to match the article tag

I have been trying to create a regex to match the article tag and get all the text .

Here is my article tag-

<article id="post-82" class="post-82 post type-post status-publish format-standard hentry category-publishing">
<div class="entry-content clearfix">
<div class="abh_box abh_box_up abh_box_drop-down"><ul class="abh_tabs"> <li class="abh_about abh_active">
<p>With India playing host,</p>
<footer class="entry-meta-bar clearfix"><div class="entry-meta clearfix">
<span class="comments"><a href="">No Comments</a></span>


I need everything which is inside the article tag.So far I have tried the following Regex-

<article (.*?)</article>


None of them works .Please help.

Answer Source

Don't use regex for parsing of HTML. Use Html parser like Html Agility pack

HtmlDocument doc = new HtmlDocument();

var result = doc.DocumentNode.SelectNodes("article").FirstOrDefault();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download