/^(?:[^f]+|f(?!oo))*$/; # Matches strings not containing 'foo'. /^(?:(?!PATTERN).)*$/; # Matches strings not containing PATTERN.