Reputation: 2811
I was trying to extract ID which is in HTML page within href. Html looks like below
<p>To register your account, please click the following link:</p>
<p><a href="https://abc-api-test.mywebsites.net:443/#/userreg/99978f1c-4c04-41ac-abcb-5039658a1f52" target="_blank">Complete registration.</a></p>
<p>If you have any questions please do not hesitate to contact us at <a href="mailto:[email protected]">
Basically I want to extract 99978f1c-4c04-41ac-abcb-5039658a1f52
value from the above.
Thanks
Upvotes: 0
Views: 194
Reputation: 383
Please try this
// specify Regular expression
Regex pageParser = new Regex(@"href=[""|']https://abc-api-test.mywebsites.net:443/#/userreg/(?<ID>[\S]*?)[""|']", RegexOptions.IgnoreCase | RegexOptions.Multiline);
// extract matches from your HTML
MatchCollection matches = pageParser.Matches(yourHtml);
//Iterate through each match
foreach (var m in matches)
{
var id = m.Groups["ID"].Value;
// do whatever you want with the ID
}
Upvotes: 2