I need a regular expression that ensures that the string contains at least 3 different characters (of any type).
Example: aqaqaq is invalid because it consists of only two different characters. aqwaqa or aq3aqa or aq! aqa.
Is this possible in regular expression?
Languages: Javascript / PHP
thank
You can use this regex containing negative images:
/(.).*(?!\1)(.).*(?!\1)(?!\2)(.)/
Examples:
> regex = /(.).*(?!\1)(.).*(?!\1)(?!\2)(.)/ > regex.exec('abab!aba') ["abab!ab", "a", "!", "b"] > regex.exec('abababa') null