using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?!(?<=pla)ng)(?!(?<=a)nlag)(?!(?<=i)nvest|nfo|nfra)(?!(?<=zuku)nft)nn?(?!finiti)[bcfgjklmpqrsvwxy](?!chaft|ormatio|eg(t|ung|e|s|itiv))";
string input = @"MATCH:
nonsense|waning|cannnnns|banger|fancy
NO MATCH:
plang|anlag|invest|warn|zukunft|design|mënsch|längt|telefo|termin|ioun|immun
plangens
pplang|clanlags|infrared|amazukunft
cannon|wand|hone|banana
BUT: Zukunftsunpassung (should match 'unpass' but not 'zukunft' and not 'ung')
Eegenschaftsunklang (should match 'Unkl' but not 'Eegenschaft' and not 'klang')";
RegexOptions options = RegexOptions.Multiline | RegexOptions.IgnoreCase;
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