fork(5) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. private static readonly Regex rxFirst5Words = new Regex(@"^\W*\w+(?:\W+\w+){4}", RegexOptions.Compiled);
  10.  
  11. public static void Main()
  12. {
  13. var s = "The quick_brown, fox1 jumps over the lazy dog";
  14. var result = rxFirst5Words.Match(s);
  15. if (result.Success)
  16. Console.WriteLine(result.Value);
  17. }
  18. }
Success #stdin #stdout 0.02s 30512KB
stdin
Standard input is empty
stdout
The quick_brown, fox1 jumps over