fork(1) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Linq;
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var str = "Mohamed, Hamada and Mahmoud match, but not hammer";
  9. var letters = "mahd";
  10. var pat = string.Format(@"\b{0}\w+\b", string.Join("", letters.Select(s => string.Format(@"(?=\w*{0})", s))));
  11. var result = Regex.Matches(str, pat, RegexOptions.IgnoreCase)
  12. .Cast<Match>()
  13. .Select(match => match.Value)
  14. .ToList();
  15. Console.WriteLine(String.Join("\n", result));
  16. }
  17. }
Success #stdin #stdout 0.03s 30728KB
stdin
Standard input is empty
stdout
Mohamed
Hamada
Mahmoud