-1

I have a html content and somewhere inside i have this line:

<span>(48 עמודים סה"כ )</span>

What i need is to get only the 48 עמודים סה"כ And to put the number in this case 48 in int variable. In this case the number is 48 but it can be any other number in other cases.

The problem is that it's also inside the ( )

What i need to get is what inside the () And the number to be int

  • have you heard of `Html Parser` or a tool called `Agility Pack` take a look here http://stackoverflow.com/questions/25528126/c-sharp-get-text-which-replaces-text-from-span-tags-of-an-html-code – MethodMan Feb 24 '15 at 16:06
  • 3
    You need an HTML parser (like the one in the [Html Agility Pack](http://htmlagilitypack.codeplex.com/)). The commonly suggested alternative of a regex only leads to [madness](http://stackoverflow.com/a/1732454/67392). – Richard Feb 24 '15 at 16:08
  • For this not too complex example regex would work but of course if you do not know of what complexity future html-content might be, you better use a html-parser right away. – Paul Weiland Feb 24 '15 at 16:13

1 Answers1

0

Assuming you've already got value of inner text (i.e. with HtmlAgilityPack - Parsing HTML with c#.net) than simple String.Trim will give you part without outer braces (may also need additional characters to trim whitespaces):

  var inner = "(48 עמודים סה"כ )".Trim('(',')');
Community
  • 1
  • 1
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179