using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"\b(?i)[a-z-0-9‑]*?(?:plang|anlag|invest|warn|info|zukunft|design|enk|infra|insta|mënsch|liewens|vinyl|finnl|onge|längt|maintenance|dank|tank|vereinfach|einfach|fanger|gung|reng|keng|telefo|termin|ioun|immun|schwenk|nsl|lang|laang)[a-z-0-9‑]*?nn?[bcfgj-mp-sv-y](?!(chaft|ormatio|initi|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;
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