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
Post a Comment