0

Within HTML code, I am trying to extract an email address only if it is provided by the user. Here is a sample of the HTML:

<div class="header">
 <div class="details">
   <span>
     <!-- Random description here which MAY contain an email address -->
   </span>
 </div>
</div>

I have managed to get to <span>by using HTML Agility Pack as follows:

var getWeb = new HtmlWeb();
var pageHtml = getWeb.Load("website here");
IEnumerable<string> listItemHtml = pageHtml.DocumentNode.SelectNodes(
                    @"//div[@class='header']
                    /div[@class='details']
                    /span").Select(span => span.InnerText);

My next challenge is to search through this text and check if an email has been provided, which I am unable to figure out. Could someone please help me with this?

craig-nerd
  • 718
  • 1
  • 12
  • 32
  • You **could** use a regexp but then you'd have the regexp as a second problem :) – Irwene Jul 27 '17 at 10:07
  • Possible duplicate of [How to validate email address in JavaScript?](https://stackoverflow.com/questions/46155/how-to-validate-email-address-in-javascript) – Hung Cao Jul 27 '17 at 16:52

0 Answers0