Anyone keen to show me how to get the integer part from this string using c#?
string url = "/{localLink:1301}";
I've been into using something like this but didn't get it to work properly
var getNumeric = new Regex(".*([0-9]+)");
Anyone keen to show me how to get the integer part from this string using c#?
string url = "/{localLink:1301}";
I've been into using something like this but didn't get it to work properly
var getNumeric = new Regex(".*([0-9]+)");
Your expression could be as simple as \d+, given the assumption that there will be only one number in your input. Still under that assumption, using ToString on the resulting Match will give you what you are looking for.
var regex = Regex.Match("/{localLink:1301}", @"\d+");
var result = regex.ToString();
Your .* is greedy. you either need .*? or [^\d]*
new Regex( ".*?(\d+)" );
.* before the [0-9]+ was matching the first 3 numeric digits since . matches any character.