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

Поиск
Список
Период
Сортировка
От Christophe Pettus
Тема Re: How best to work around the issue - regex string cannot contain brackets
Дата
Msg-id 7AF5777D-148E-4534-B442-891A911B0D2B@thebuild.com
обсуждение исходный текст
Ответ на How best to work around the issue - regex string cannot contain brackets  (Shaozhong SHI <shishaozhong@gmail.com>)
Ответы Re: How best to work around the issue - regex string cannot contain brackets  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-sql

> On Feb 3, 2022, at 08:53, Shaozhong SHI <shishaozhong@gmail.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?

You escape the ()s with a backslash:

xof=# select regexp_matches('Department for Transport (Parking)', 'Department for Transport \(Parking\)', 'g');
             regexp_matches
----------------------------------------
 {"Department for Transport (Parking)"}
(1 row)




В списке pgsql-sql по дате отправления:

Предыдущее
От: Shaozhong SHI
Дата:
Сообщение: How best to work around the issue - regex string cannot contain brackets
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: How best to work around the issue - regex string cannot contain brackets