Page 1 of 1

MySQL regexp for Latin and non Latin characters

Posted: Mon Nov 23, 2020 1:45 pm
by axew3

Code: Select all

SELECT username FROM users WHERE username REGEXP [^-0-9A-Za-z _.@]
will detect Денис И. as containing unwanted characters, even if it do not contain unwanted characters, based on above regexp,
Денис И. in non Cyrillic, but in Latin chars it is Denis I. and so should be accepted as valid.

To resolve this issue, i've find out into MySQL documentation a possible easy solution, because alnum (alphabetic/numbers in place of a-zA-Z0-9) do not take care of what kind of characters it found, and manage/return the correct result in this way:

Code: Select all

SELECT username FROM users WHERE username REGEXP [^-[:alnum:] _.@]
MySQL reference: https://dev.mysql.com/doc/refman/8.0/en/regexp.html

Any other i've try fail, but if anybody know how could be possible to achieve the same in different way please let know!