For example, I have this string that could change anytime I only want the alphabetic text from it:
Ferrari 5 10 15000 -5 0.2
So from that I want "Ferrari".
Sometimes there won't be a space between "Ferrari" and the numbers.
string str = "Ferrari 5 10 15000 -5 0.2";
string text = Regex.Match(str, @"[a-zA-Z\s]+").Value.Trim();
By also matching whitespace and then trimming the result, It will match "Some Car" in "Some Car 5 10 ...".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With