Re: How can i escape a '+' or a '+' in a regexp ?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Gabriel Fernandez <gabi(at)unica(dot)edu>
Cc: PostgreSQL SQL discussion list <pgsql-sql(at)postgresql(dot)org>
Subject: Re: How can i escape a '+' or a '+' in a regexp ?
Date: 2001-02-23 18:44:03
Message-ID: Pine.BSF.4.21.0102231042360.17822-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


I believe you'll need two \ characters to escape the + or *.
titulo ~ '\\+'

On Fri, 23 Feb 2001, Gabriel Fernandez wrote:

> Hi fellows,
>
> I'm trying to the following query:
>
> select * from areas where titulo ~ '+' or titulo ~ '*'
>
> and the answer is:
>
> ERROR: regcomp failed with error repetition-operator operand invalid
>
> I have tried to escape the '+' and the '*' with a backslash, as
> follows:
>
> select * from areas where titulo ~ '\+' or titulo ~ '\*'
> but the answer is the same.
>
> If I use the LIKE operator, then I have the problem with '%' and '_'
> :-)
>
> As long as the values in the field can contain either '+' or '*' or '%'
> or '_' I need to escape these characters. How can i do it ?

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Dave Page 2001-02-23 21:00:07 RE: select * from pgadmin_users; causes error
Previous Message Jie Liang 2001-02-23 18:39:41 Re: How can i escape a '+' or a '+' in a regexp ?