Find all rows using some Unicode range (such as Cyrillic characters) with PostgreSQL?

后端 未结 2 1532
天命终不由人
天命终不由人 2021-01-02 10:47

How do I find all rows of a PostgreSQL table that contain characters in some Unicode range, such as Cyrillic characters?

相关标签:
2条回答
  • 2021-01-02 11:30

    Figured it out! For Cyrillic:

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

    I got the range from http://symbolcodes.tlt.psu.edu/bylanguage/cyrillicchart.html. The characters have hex entities А to я, which are also my numbers above.

    0 讨论(0)
  • 2021-01-02 11:38

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

    SELECT * FROM items WHERE title ~ pcre '\p{Cyrillic}';
    
    0 讨论(0)
提交回复
热议问题