Advertisement
sec_goat

Match Lines Not Starting with Pattern

Feb 20th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. Regex startsWith = new Regex("^<catalog", RegexOptions.Singleline);
  2. List<String> combinedLines = new List<string>();
  3.            
  4.             string lastline = ""; //for keepign track of the last line in case we need to merge the two
  5.            
  6.             foreach (var line in File.ReadLines(filepath))
  7.             {
  8.                
  9.                 Match match = startsWith.Match(line.Trim());
  10.                 if (!match.Success)
  11.                 {
  12.                     found_matching_lines = true;
  13.                     combinedLines.Add(lastline.Trim() + line.Trim());
  14.                 }
  15.                 lastline = line;
  16.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement