Postgresql Regular Expressions

0

Personal speech, I need some help

I'm trying to make a trigger in postgresql that checks if the format of a new data being 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 is in format verification, so it's currently NEW.telefone LIKE '^+([^0-9]{2}[^)][^0-9]{5}[^-][^0-9]{4}'

I'm new to regular expressions and I'm kind of lost, could you help me with this?

    
asked by anonymous 07.12.2017 / 15:47

1 answer

0

Personally I solved the problem here, I was setting up the regular expression in the wrong way, here is the correct way

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

    
07.12.2017 / 17:33