"Steve Wolfe" <steve(at)iboats(dot)com> writes:
> How does one escape parenthesis in a regular expression in Postgres?
> select * from subcategories where subcategory ~* '401\(k\)';
> That still didn't work.
You need two backslashes:
select * from subcategories where subcategory ~* '401\\(k\\)';
The first of each pair gets eaten by the parser when the string literal
is parsed, so what arrives at the ~* operator at runtime is
401\(k\)
which is what you need.
regards, tom lane