Regex cut number in a string c# -
i have string following 2 - 5
want number 5 regex c# (i'm new regex), suggest me idea?
you can use string.split
method simply:
int number = int.parse("2 - 5".split('-', ' ').last());
this work if there no space after last number.if case then:
int number = int.parse("2 - 5 ".split('-', ' ') .last(x => x.any() && x.all(char.isdigit)));
Comments
Post a Comment