using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?<!(?:[%]{2})*[%])[%][sidfoOc]";
string input = @"# Basic - Expandable object format string
Format string object: %o
# Basic - Single string format string
Format string string: %s
# Basic - Single integer format string
Format string integer: %i
# Basic - Single integer format string
Format string integer: %d
# Advanced - Message with expandable object, string, and integer format strings
Raw value: %o\nTo string: %s\nAs number: %i
# Advanced - Formatted message with styled heading, and body with value, escaped percentage
%c[Header]%c msg about %i values (%o)
%c[Header]%c msg about %i objects, %i%% total%c\n Object array: %o";
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