Přejít na menu

MySQL REGEXP

Správa článků

Vyhledávání Vyhledávání
24.2.2014 15:12
,
Počet přečtení: 695

Tips and problems with regular expressions is MySQL.

MySQL reference

Word boundaries: [[:<:]] [[:>:]]

Problems with UTF-8

REGEXPs doesn't support utf-8 chars!

For example "SELECT 'koš' REGEXP 'ko[[:alnum:]]';" returns 1 in command-line, but when matching against some utf-8 col stored in the DB it returns 0.

http://stackoverflow.com/questions/19774618/mysql-regex-utf-8-characters

Workaround with HEXa conversion:

# SELECT HEX("fotografický") => 666F746F6772616669636BC3BD
# Hexa of space = 20, tab = 09, newline = 0a
SELECT HEX("a fotografický seminář") REGEXP '(20|09|0a|^)666F746F6772616669636BC3BD(20|09|0a|$)';

Vytvořil 24. února 2014 v 15:22:31 mira. Upravováno 3x, naposledy 21. dubna 2014 ve 20:23:40, mira


Diskuze ke článku

Vložení nového komentáře
*
*
*