using regex to get the variable value of html tags
c#, html-parsing
Solution
string html = "<meta itemprop=\"rating\" content=\"4.7\">";
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
var content = doc.DocumentNode
.Element("meta")
.Attributes["content"].Value;
--EDIT--
From your first accepting and then unaccepting the answer, I guess you took the code and run with your real html and saw that it returned wrong result.
This doesn't show that the answer is not correct since It works correctly with the snippet you posted.
So by making a wild guess and assuming that there are other `meta` tags in your real html with `itemprop` attributes like
<meta itemprop="rating" content="4.7">
<meta itemprop="somekey" content="somevalue">
the code would be:
var content = doc.DocumentNode
.Descendants("meta")
.Where(n => n.Attributes["itemprop"] != null && n.Attributes["itemprop"].Value == "rating")
.Select(n => n.Attributes["content"].Value)
.First();
Problem
I am trying to get a value in between certain text of html , so far not successful ,I can not use html aglity pack as it gives the data only present in between html tags ``` public static string[] split_comments(string html) { html = html.ToLower(); html = html.Replace(@""""," "); ``` the actual line in html is this //`<meta itemprop="rating" content="4.7"> the 4.7 value changes every time and I need to get this value` ``` Match match = Regex.Match(html, @"<meta itemprop=rating content=([A-Za-z0-9\-]+)\>$"); if (match.Success) { // Finally, we get the Group value and display it. string key = match.Groups[1].Value; } ``` So I am trying to get a tag of html and in that tag I wish to get the data whic is variable all the time .