Re: How best to work around the issue - regex string cannot contain brackets

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Christophe Pettus <xof(at)thebuild(dot)com>
Cc: Shaozhong SHI <shishaozhong(at)gmail(dot)com>, pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Re: How best to work around the issue - regex string cannot contain brackets
Date: 2022-02-03 17:04:42
Message-ID: CAKFQuwYbkOta7upAttZMRCBFVrLozMtygZ=jmWN41ad5C+BnKg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, Feb 3, 2022 at 9:58 AM Christophe Pettus <xof(at)thebuild(dot)com> wrote:

>
>
> > On Feb 3, 2022, at 08:53, Shaozhong SHI <shishaozhong(at)gmail(dot)com> wrote:
> >
> > One would consider the following would work, but it did not because the
> brackets.
> > select regexp_matches('Department for Transport (Parking)', 'Department
> for Transport (Parking)', 'g')
> >
> > Can anyone enlighten me?
>

Have you tried reading a book or some tutorials on RegExes? I'll admit our
documentation is probably not the best resource out there to actually learn
the language.

> You escape the ()s with a backslash:
>

More generally this behavior this documented as "\k"

https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-POSIX-REGEXP

David J.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message aditya desai 2022-02-04 03:50:45 Re: Increase fetch fize of oracl_fdw(ALTER SERVER)
Previous Message Christophe Pettus 2022-02-03 16:58:45 Re: How best to work around the issue - regex string cannot contain brackets