I need to get value of XML:
<usr_clan_id>123</usr_clan_id>
I need get 123, its example. I'll tried to use:
Match match = Regex.Match(input, @"<usr_clan_id>([0-9])</usr_clan_id>$",
RegexOptions.IgnoreCase);
But it's bad :/
I need to get value of XML:
<usr_clan_id>123</usr_clan_id>
I need get 123, its example. I'll tried to use:
Match match = Regex.Match(input, @"<usr_clan_id>([0-9])</usr_clan_id>$",
RegexOptions.IgnoreCase);
But it's bad :/
Simplest solution
XDocument xdoc = XDocument.Parse(@"<usr_clan_id>123</usr_clan_id>");
int id = (int)xdoc.Element("usr_clan_id");
Int32.TryParse((string)xdoc.Element("usr_clan_id"), out value) will do the job without exception.If you get a huge XML file, use a parser and get the value with XPath as suggested in the comments. If you only get the short XML string you included in your question, RegEx is perfectly fine in my opinion.
About the regular expression: You only match one digit. Instead use + which matches one or more digits.
@"<usr_clan_id>([0-9]+)</usr_clan_id>$"