Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace P04_PunctuationFinder
- {
- class PunctuationFinder
- {
- static void Main()
- {
- string textFromFile = File.ReadAllText("sample_text.txt");
- Regex regex = new Regex(@"[,\.!?\:]");
- var match = regex.Matches(textFromFile);
- List<string> charList = new List<string>();
- foreach (Match item in match)
- {
- charList.Add(item.Value);
- }
- Console.WriteLine(string.Join(", ", charList));
- //String[] input = File.ReadAllLines("sample_text.txt");
- //List<char> punctoationChars = new List<char>();
- //char[] punctList = new[] {',', '.', '!', '?', ':'};
- //foreach (string line in input)
- //{
- // for (int i = 0; i < line.Length; i++)
- // {
- // if (punctList.Contains(line[i]))
- // {
- // punctoationChars.Add(line[i]);
- // }
- // }
- //}
- //Console.Write(string.Join(", ", punctoationChars));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement