Good time of day! Using HtmlAgilityPack, I get a line from the source code:

<div class="b-auth"> <a class="b-link" href="/personal/" >10000031007</a>(<span class="b-user-acc b-user-acc_type_deb">Аванс: </span>113,04 | <a class="b-link" href="/?logout=yes" >Выход</a>) </div> 

The question is how to pull out the value 113.04 using regulars or in any other way.

4 answers 4

Regulars are good, I love them and often use them.

However, html is an irregular grammar, so regular expressions are poorly suited for parsing.

To make sure not to make a mistake, you can first get the text nodes with the help of the HtmlAgilityPack tools, and then parse the regexes.

 // Узел, содержащий приведённый в вопросе html. var divNode = ... var textNodes = divNode.ChildNodes.OfType<HtmlTextNode>(); foreach (var node in textNodes) { var match = Regex.Match(node.Text, @"\d+,\d+"); if (match.Success) { Console.WriteLine(match.Value); // нужное нам значение break; } } 
  • For a change, I can advise the author of the question to pay attention to AngleSharp . - Anton Komyshan pm

regular expression / \ d +, \ d + /

    I have got such a pattern in the required number: (?<=[>])[\d][\d,]*(?=\s\|)

    However, it is better to do such things with the HTML parser.

      Thank you all for the help! It turned out this miracle. Slightly finalized for themselves.

       //Перевел в текст через HtmlAgilityPack и вабрал значение до 1 000,00 // Узел, содержащий html. var data = ...; var match = Regex.Match(Convert.ToString(data.InnerText), @"\d+.\d+,\d+");