I have below regular expression
^(?!\\d+$)(?!(?:[^$&%@]*[$&%@]){4})(?!.*\\b\\w{11}).{3,}$
it is working fine in PHP
I want
MySQL does not support lookarounds, nor does it support \d
or \w
classes. You may split the regex like that:
SELECT * FROM table WHERE col REGEXP '^.{3,}$' AND col NOT REGEXP '^[0-9]+$' AND col NOT REGEXP '([^$&%@]*[$&%@]){4}' AND col NOT REGEXP '[[:<:]][[:alnum:]_]{11}'
Where:
REGEXP '^.{3,}$'
- the total length should be 3 or more charactersAND col NOT REGEXP '^[0-9]+$'
- string cannot consist of digits onlyAND col NOT REGEXP '([^$&%@]*[$&%@]){4}'
- string cannot have 4 special charsAND col NOT REGEXP '[[:alnum:]_]{11}'
- string cannot have a word with 11 chars