postgresql – Postgres Error with regex for finding phone numbers, ERROR: invalid regular expression: quantifier operand invalid
I am trying to find phone numbers that fit into the following regex in postgres on one particular field. Im getting the error ERROR: invalid regular expression: quantifier operand invalid but not sure why. It seems like legitimate regex but fails when I try to run.
~'^([0-9]( |-)?)?(\\(?[0-9]{3}\\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$'
Any help would be great!
Ive tried escaping the | but it didn’t seem to help. Tried looking at other questions on here on regex but haven’t been able to figure it out.
Read more here: Source link
