I have below regular expression
^(?!\\d+$)(?!(?:[^$&%@]*[$&%@]){4})(?!.*\\b\\w{11}).{3,}$
it is working fine in PHP
I want
The work around is to use preg-like MySQL UDF Library that has more complex REGEXP than the native MySQL's own.
https://github.com/mysqludf/lib_mysqludf_preg
and you can type the above in the link below to get Perl version of the expression that will work directly with the udf
https://regex101.com/r/wU8uM7/22/codegen?language=javascript
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