Get non numeric values from string value c# -


i have value below

string value = "11,.ad23"; int n; bool isnumeric = int.tryparse(value, out n); 

i control if string numeric or not.if string not numeric , has non numeric need get non numeric values below

result must below

,.ad 

how can in c# ?

if doesn't matter if non-digits consecutive, it's simple:

string nonnumericvalue = string.concat(value.where(c => !char.isdigit(c))); 

online demo: http://ideone.com/cromht

if use .net 3.5. mentioned in comment there no overload of string.concat (or string.join in dmytris answer) takes ienumerable<string>, need create array:

string nonnumericvalue = string.concat(value.where(c => !char.isdigit(c)).toarray()); 

that takes non-digits. if instead want take middle part, skip digits, take until the next digits:

string nonnumericvalue = string.concat(value.skipwhile(char.isdigit)                                             .takewhile(c => !char.isdigit(c))); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -