Advertisement
blazarow09

Untitled

Jun 19th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Linq;
  4.  
  5. namespace ExtractSentences
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var key = Console.ReadLine();
  12. var inputText = Console.ReadLine();
  13.  
  14. var pattern = $"[^.!?;]*(({key}\\W)|(\\W{key}\\W))[^.!?;]*";
  15.  
  16. var matches = Regex.Matches(inputText, pattern);
  17. var count = 0;
  18. foreach (Match match in matches)
  19. {
  20. if (count == 0)
  21. {
  22. Console.WriteLine(match.ToString());
  23. }
  24. else
  25. {
  26. var sentence = Convert.ToString(match);
  27. Console.WriteLine(sentence.Substring(1));
  28. }
  29.  
  30. count++;
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement