Postgresql regular expressions

Asked

Viewed 605 times

0

Come on, guys, I need some help

I’m trying to make a Rigger in postgresql that checks whether the format of a new data to be inserted into a table is in a certain format, in this case the phone format.

I need the new phone to be inserted in the format +pp(dd)nnnnn-nnnn

My problem lies in checking the format, currently it is like this NEW.telefone LIKE '^+([^0-9]{2}[^)][^0-9]{5}[^-][^0-9]{4}'

I’m new to regular expressions and I’m a little lost, could you help me with this?

1 answer

0


Guys I managed to solve the problem here, I was setting up regular expression in the wrong way, here’s the right way

NEW.telefone ~ '^\+[0-9]{2}\([0-9]{2}\)[0-9]{5}\-[0-9]{4}$'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.