re = /(?!(?<=pla)ng)(?!(?<=a)nlag)(?!(?<=i)nvest|nfo|nfra)(?!(?<=zuku)nft)nn?(?!finiti)[bcfgjklmpqrsvwxy](?!chaft|ormatio|eg(t|ung|e|s|itiv))/mi
str = '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\')'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html