On the postgres command line, I tried this:
select
regexp_matches('file?device_id[]=555', 'device_id\[\]=(\d+)', 'g') as dev_id;
I get this error:
ERROR: invalid regular expression: brackets [] not balanced
When I run this same query in HeidiSQL it returns with no errors. I don't understand why the CLI thinks the brackets are unbalanced when I'm escaping them. Just for testing, I tried anywhere from 0 to 3 backslashes to escape the brackets, and none of those worked.
1 Answer 1
I managed to find the answer in this thread:
https://stackoverflow.com/questions/618350/escaping-bracket-in-postgresql-query
After running
set standard_conforming_strings=1;
It now returns the expected 555.
-
Must be an issue with your server setup - as far as I can see, the normal setup returns the correct answer!Vérace– Vérace2021年12月07日 16:49:04 +00:00Commented Dec 7, 2021 at 16:49
dev_id {555}
for me!psql