Ответ Алиостада правильный, просто добавьте к нему опцию RegexOptions.IgnoreCase
, если вы хотите безразлично поймать Dear
и dear
string expression = @"dear(\d+)";
string myString = "HimyDear139friend mydear111sayhi1234 imissdear121212 dear123likeorange";
MatchCollection matches = Regex.Matches(myString, expression);
foreach(Match m in matches)
Console.WriteLine(m.Groups[1].Value);
Console.WriteLine("Ignoring Case Option Enabled");
matches = Regex.Matches(myString, expression, RegexOptions.IgnoreCase);
foreach (Match m in matches)
Console.WriteLine(m.Groups[1].Value);
Надеюсь, что помогло;)