Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- string textFromFile = System.IO.File.ReadAllText(@"input.txt", Encoding.UTF8);
- Console.WriteLine(textFromFile);
- Console.WriteLine();
- char[] charsFromText = textFromFile.ToString().ToLower().ToCharArray();
- int words = 0;
- int chars = 0;
- Regex findWords = new Regex(@"([а-яА-Яa-zA-Z0-9]+)");
- MatchCollection matches = findWords.Matches(textFromFile);
- foreach (Match match in matches)
- {
- words++;
- }
- Regex findChars = new Regex(@"[\.\?\!\,\;\:\-\(\)\""\']");
- matches = findChars.Matches(textFromFile);
- foreach (Match match in matches)
- {
- chars++;
- }
- Console.WriteLine("Количество слов " + words + " количество знаков препинания " + chars);
- Console.Read();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement