To match a whole string consisting of English letters, use LINQ or regex:
var hasAllEnglishLetters = x.All(c => (c >= 65 && c <= 90) || c >=97 && c<= 122));
var hasAllEnglishLetters = Regex.IsMatch(x, @"^[a-zA-Z]+$");
To match words inside a larger string, you may either use a regex or LINQ approaches, too:
var s = "Match word but not word1, w1ord or word!";
var res_linq = s.Split().Where(x => x.All(c => (c >= 65 && c <= 90) || c >=97 && c<= 122));
Console.WriteLine(string.Join(";", res_linq));
// REGEX
var res_regex = Regex.Matches(s, @"(?<!\S)[a-zA-Z]+(?!\S)").Cast<Match>().Select(m=>m.Value);
Console.WriteLine(string.Join(";", res_regex));
See the online C# demo
LINQ approach details: With Split()
, the string is split into chunks of non-whitespace symbols and .All(c => (c >= 65 && c <= 90) || c >=97 && c<= 122)
makes sure only those chunks are fetched that belong to ASCII letters (65 to 90 - uppercase ASCII letters, and 97 to 122 are lowercase ones).
Regex approach: the (?<!\S)
lookbehind fails the match if there is no whitespace before [a-zA-Z]+
(or start of string), 1 or more ASCII letters, and the negative lookahead (?!\S)
fails the match if there is no whitespace (or end of string) after the letters.