WolfyD
WolfyD

Reputation: 873

Matching multiple hex characters in a PGSQL Regex

I'm trying to find some very specific multibyte characters in PostgreSQL using Regex. I know I have the option to make a long CASE WHEN but i decided to check if there is a different way to finding these.

My current Regex looks like this E'\xf0\x9f\x98\x83' This works pretty well, except that I would need to find all from \xf0\x9f\x98\x80 to \xf0\x9f\x98\x99.

In JS I would just be able to write something like \xf0\x9f\x98[\x80-\x89] but for whatever reason this returns an error in PGSQL. Is there a shortcut like this, or am I doomed to writing 20 CASE WHEN-s?

Upvotes: 1

Views: 670

Answers (1)

WolfyD
WolfyD

Reputation: 873

I have realized my mistake. PGSQL Error was caused because I'm looking for 4 byte characters and I just wanted to mess with the last byte. I realized I'd have to write it like this: E'[\xf0\x9f\x98\x80-\xf0\x9f\x98\x90]'

Upvotes: 1

Related Questions