I need to delete all english letters in a string.
I wrote the following code:
StringBuilder str = new StringBuilder();
foreach(var letter in test)
{
if(letter >= 'a' && letter <= 'z')
continue;
str.Append(letter); }
What is the fastest way?
use Regex replace method, and give it [a-z]|[A-Z]
Try this:
var str = test.Where(item => item < 'A' || item > 'z' || (item > 'Z' && item < 'a'));
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