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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With