.net - Easiest way to extract 4 digit number out of string? -


if know string going like:

abc xyz 5678

or

qweroi yreoiu 4679

what best way extract last 4 digit string?

in c# whole thing

string mystring = "qweroi yreoiu 4679"; regex regex = new regex(@"\d{4}$"); match result = regex.match(mystring); 

you can use .tostring() if need keep working match. additional information regex recommend this article.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -