using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?x) # invoke extended (aka free-spacing) mode
^ # match beginning of the string
[^""\n]* # match zero or more chars other than line terminators and double-quotes
"" # match a double-quote
[^""\n]* # match zero or more chars other than line terminators and double-quotes
[^ ""\n] # match a character other than a space, double-quote or newline
"" # match a double-quote
\n # match a newline
\ * # match zero or more spaces
"" # match double-quote
[^ ""\n] # match a character other than a space, double-quote or newline
[^""\n]* # match zero or more chars other than line terminators and double-quotes
"" # match a double-quote
\n? # optionally match a newline
$ # match end of string";
string input = @"abc def ""ghi jkl\n""
""mno pqr""";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
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