using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; class Program { static int Main(string[] args) { foreach (string line in args[0] == "-" ? ReadConsole() : File.ReadLines(args[0])) { Match mm = Regex.Match(line, args[1]); if (mm.Success) { Console.WriteLine( mm.Groups.Count == 1 ? mm.Value : string.Join("", mm.Groups.OfType().Skip(1).Select(g => g.Value))); return 0; } } return 1; } static IEnumerable ReadConsole() { while (true) { string line = Console.ReadLine(); if (line == null) { yield break; } else { yield return line; } } } }