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

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

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -

collision detection - C++ library for mesh to mesh intersection: what is available? -