Find all rows using some Unicode range (e.g. Cyrillic characters) with PostgreSQL?

How to find all rows of a PostgreSQL table containing characters in some Unicode ranges, for example Cyrillic characters?

+6
source share
2 answers

I thought! For Cyrillic:

SELECT * FROM "items" WHERE (title SIMILAR TO '%[\u0410-\u044f]%') 

I got a range from http://symbolcodes.tlt.psu.edu/bylanguage/cyrillicchart.html . Characters have hexadecimal objects А before я which are also my numbers above.

+11
source

If you install the pgpcre extension, you can use this expression:

 SELECT * FROM items WHERE title ~ pcre '\p{Cyrillic}'; 
+2
source

Source: https://habr.com/ru/post/957423/


All Articles