Re: problem with regexp (cant quote +)

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: problem with regexp (cant quote +)
Дата
Msg-id 20030705205334.GB17982@dcc.uchile.cl
обсуждение исходный текст
Ответ на problem with regexp (cant quote +)  (peter pilsl <pilsl@goldfisch.at>)
Список pgsql-general
On Sat, Jul 05, 2003 at 04:46:47PM +0200, peter pilsl wrote:
>
> I wonder why the following expression fails. I came to this wondering why I
> could not search for + using the '~'-operator.
>
> select 'ok' where 'H+H'~'H\+H';

You need to double the backslash, because the first one is going away at
parse time (you need a literal \ for the regex).

alvh=> select 'ok' where 'H+H' ~ 'H\\+H';
 ?column?
----------
 ok
(1 row)

Yeah, annoying, but easily understood.  Other tools behave the same:
$ echo 'H+H' | egrep H+H
$ echo 'H+H' | egrep H\+H
$ echo 'H+H' | egrep H\\+H
H+H

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"I dream about dreams about dreams", sang the nightingale
under the pale moon (Sandman)

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

Предыдущее
От: Tino Wildenhain
Дата:
Сообщение: Re: problem with regexp (cant quote +)]
Следующее
От: "Robert Wille"
Дата:
Сообщение: Re: Record locking in deadlock