using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(\d+)\. ?(.+?)(?:value|vlaue|balue|valie): ?(.+?)[\n\r]{2,}";
string substitution = @"";
string input = @"Some junk data
More junk data
1. fairly long key, all on one line
value: some other text with spaces and stuff
Some junk data
More junk data
2. hey look! another long
and broken key. on two lines
value: a different value with some different information
Some junk data
More junk data
3. hey look! another long line. on a line
value: a different value
broken, with some different information
Some junk data
More junk data ";
RegexOptions options = RegexOptions.Multiline | RegexOptions.Singleline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx