Mega Code Archive

 
Categories / C# Book / 11 Regular Expression Basics
 

0653 Lines of at least 80 characters

using System; using System.Text.RegularExpressions; class Program { static void Main(string[] args) { string r = @"(?m)^.{80,}(?=\r?$)"; string fifty = new string ('x', 50); string eighty = new string ('x', 80); string text = eighty + "\r\n" + fifty + "\r\n" + eighty; Console.WriteLine (Regex.Matches (text, r).Count); // 2 } } The output: 2