Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. string textFromFile = System.IO.File.ReadAllText(@"input.txt", Encoding.UTF8);
  4. Console.WriteLine(textFromFile);
  5. Console.WriteLine();
  6. char[] charsFromText = textFromFile.ToString().ToLower().ToCharArray();
  7. int words = 0;
  8. int chars = 0;
  9.  
  10. Regex findWords = new Regex(@"([а-яА-Яa-zA-Z0-9]+)");
  11. MatchCollection matches = findWords.Matches(textFromFile);
  12. foreach (Match match in matches)
  13. {
  14. words++;
  15. }
  16. Regex findChars = new Regex(@"[\.\?\!\,\;\:\-\(\)\""\']");
  17.  
  18. matches = findChars.Matches(textFromFile);
  19. foreach (Match match in matches)
  20. {
  21. chars++;
  22. }
  23. Console.WriteLine("Количество слов " + words + " количество знаков препинания " + chars);
  24. Console.Read();
  25.  
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement