From: | Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> |
---|---|
To: | peter pilsl <pilsl(at)goldfisch(dot)at> |
Cc: | PostgreSQL List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: problem with regexp (cant quote +) |
Date: | 2003-07-05 20:53:34 |
Message-ID: | 20030705205334.GB17982@dcc.uchile.cl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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)
From | Date | Subject | |
---|---|---|---|
Next Message | Hilmar Lapp | 2003-07-05 23:40:52 | Re: PostgreSQL vs. MySQL |
Previous Message | Tino Wildenhain | 2003-07-05 20:34:19 | Re: problem with regexp (cant quote +)] |