Re: [GENERAL] Quoting/Escaping

From: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
To: Bill Sneed <bsneed(at)mint(dot)net>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Quoting/Escaping
Date: 1999-11-29 15:29:39
Message-ID: l03130301b4684ba9482e@[147.233.159.109]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 23:21 +0200 on 28/11/1999, Bill Sneed wrote:

> I'd like to be able to find a book title that contain C++ in the
> title....
>
> select * from books where title ~* 'C++' doesn't work.
>
> I've tried all the basic methods of quoting the Plus (+) signs but
> none seem to work...
>
> Any hints would be most appreciated....

testing=> select * from test1;
tx
------------------------------------------------
I prefer Java to C++ programming.
C++ is the most complicated of all OO langagues.
Java has less inheritance, but it is simpler.
(3 rows)
testing=> select * from test1 where tx ~* 'C\\+\\+';
tx
------------------------------------------------
I prefer Java to C++ programming.
C++ is the most complicated of all OO langagues.
(2 rows)

Rationale: the string is processed in two stages. One, when the query is
read by Postgres. The other, when the regexp engine reads it. It needs to
have backslashes before the pluses when it reaches the second stage. So the
backslashes have to pass intact through the first stage. Thus, they have to
be escaped themselves...

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herouth/personal/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 1999-11-29 19:08:41 Re: [HACKERS] Re: [GENERAL] drop/rename table and transactions
Previous Message jose soares 1999-11-29 13:40:54 Re: [GENERAL] update view