c# - Regex to get NUMBER only from String -


i recieve "7+" or "5+" or "+5" xml , wants extract number string using regex. e.g regex.match() function

        stringthathavecharacters = stringthathavecharacters.trim();         match m = regex.match(stringthathavecharacters, "what use here");         int number = convert.toint32(m.value);         return number; 

\d+

\d represents digit, + 1 or more. if want catch negative numbers can use -?\d+.

note string, should represented in c# "\\d+", or @"\d+"


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -