You must modify the Regex template to include the repeat operator + so that it matches more than once.
[a-zA-Z] must be [a-zA-Z]+
You can get the longest value with LINQ. Order by the length of the match, and then take the first entry. If there are no matches, the result will be null .
string pattern2 = "[a-zA-Z]+"; string zad3 = "ala123alama234ijeszczepsa"; var matches = Regex.Matches(zad3, pattern2); string result = matches .Cast<Match>() .OrderByDescending(x => x.Value.Length) .FirstOrDefault()? .Value;
A string named result in this example:
ijeszczepsa
source share