string pattern = "[a|e|i|o|u]"; string input = "The quick Brown fox Jumps Over the Lazy Dog"; MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.IgnoreCase); foreach (Match match in matches) { Console.WriteLine(match.Value); }
string pattern = @"^\d{2}/\d{2}/\d{4}\s\d{2}:\d{2}:\d{2}\s.*$"; string input = @"07/06/2022 12:30:00 Message 1 07/07/2022 13:45:00 Message 2 07/08/2022 09:15:00 Message 3"; MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Multiline); foreach (Match match in matches) { Console.WriteLine(match.Value); }This code will output all three lines of the input string because they match the specified pattern. Package/Library: .NET Framework