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

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -