I am trying to escape a bracket in a pattern matching expression for PostgreSQL 8.2
The clause looks something like:
WHERE field SIMILAR TO '%UPC=\[ R%%(\mLE)%'
but I keep getting:
ERROR: invalid regular expression: brackets [] not balanced
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try this:
You need to set Postgres in standard conforming strings mode instead of backward compatible mode.
Or you need to use escape string syntax which works regardless of mode:
You can set this setting in postgresql.conf for all databases, using
alter databasefor single database, usingalter userfor single user or group of users or usingsetfor current connection.