Re: How can i escape a '+' or a '+' in a regexp ? - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: How can i escape a '+' or a '+' in a regexp ?
Date
Msg-id Pine.BSF.4.21.0102231042360.17822-100000@megazone23.bigpanda.com
Whole thread Raw
In response to How can i escape a '+' or a '+' in a regexp ?  (Gabriel Fernandez <gabi@unica.edu>)
List 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 ?



pgsql-sql by date:

Previous
From: Gabriel Fernandez
Date:
Subject: How can i escape a '+' or a '+' in a regexp ?
Next
From: Jyotsna Kypa
Date:
Subject: Need your help