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

From: Jie Liang <jliang(at)ipinc(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:39:41
Message-ID: Pine.BSF.4.10.10102231036560.55511-100000@tidal.ipinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


select field from table
where field like '%\\%%' or field like '%*%';

select field from table
where field ~ '.*\\*.*' or ~ '.*%.*';

Jie LIANG

St. Bernard Software
Internet Products Inc.

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang(at)ipinc(dot)com
www.stbernard.com
www.ipinc.com

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 ?
>
> I'm using PostgreSQL 6.5.3 on Linux Red Hat 6.2.
>
> Thanks,
>
> Gabi :-)
>
>
>
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2001-02-23 18:44:03 Re: How can i escape a '+' or a '+' in a regexp ?
Previous Message Gabriel Fernandez 2001-02-23 18:25:29 How can i escape a '+' or a '+' in a regexp ?