MySQL regexp for Latin and non Latin characters

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

If you wish to attach one or more files enter the details below.

Maximum filesize per attachment: 1 MiB.

Expand view Topic review: MySQL regexp for Latin and non Latin characters

MySQL regexp for Latin and non Latin characters

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

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!

Top