pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: How can i escape a '+' or a '+' in a regexp ?
4+ messages / 4 participants
[nested] [flat]
* How can i escape a '+' or a '+' in a regexp ?
@ 2001-02-23 18:25 Gabriel Fernandez <gabi@unica.edu>
2001-02-23 18:14 ` Re: How can i escape a '+' or a '+' in a regexp ? tjk@tksoft.com <tjk@tksoft.com>
2001-02-23 18:39 ` Re: How can i escape a '+' or a '+' in a regexp ? Jie Liang <jliang@ipinc.com>
2001-02-23 18:44 ` Re: How can i escape a '+' or a '+' in a regexp ? Stephan Szabo <sszabo@megazone23.bigpanda.com>
0 siblings, 3 replies; 4+ messages in thread
From: Gabriel Fernandez @ 2001-02-23 18:25 UTC (permalink / raw)
To: pgsql-sql
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 :-)
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: How can i escape a '+' or a '+' in a regexp ?
2001-02-23 18:25 How can i escape a '+' or a '+' in a regexp ? Gabriel Fernandez <gabi@unica.edu>
@ 2001-02-23 18:14 ` tjk@tksoft.com <tjk@tksoft.com>
2 siblings, 0 replies; 4+ messages in thread
From: tjk@tksoft.com @ 2001-02-23 18:14 UTC (permalink / raw)
To: gabi@unica.edu; +Cc: pgsql-sql
Gabriel,
Two backslashes.
> select * from areas where titulo ~ '\\+' or titulo ~ '\\*'
Troy
>
> 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 :-)
>
>
>
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: How can i escape a '+' or a '+' in a regexp ?
2001-02-23 18:25 How can i escape a '+' or a '+' in a regexp ? Gabriel Fernandez <gabi@unica.edu>
@ 2001-02-23 18:39 ` Jie Liang <jliang@ipinc.com>
2 siblings, 0 replies; 4+ messages in thread
From: Jie Liang @ 2001-02-23 18:39 UTC (permalink / raw)
To: Gabriel Fernandez <gabi@unica.edu>; +Cc: 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@ipinc.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 :-)
>
>
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: How can i escape a '+' or a '+' in a regexp ?
2001-02-23 18:25 How can i escape a '+' or a '+' in a regexp ? Gabriel Fernandez <gabi@unica.edu>
@ 2001-02-23 18:44 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2 siblings, 0 replies; 4+ messages in thread
From: Stephan Szabo @ 2001-02-23 18:44 UTC (permalink / raw)
To: Gabriel Fernandez <gabi@unica.edu>; +Cc: 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 ?
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2001-02-23 18:44 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-02-23 18:25 How can i escape a '+' or a '+' in a regexp ? Gabriel Fernandez <gabi@unica.edu>
2001-02-23 18:14 ` tjk@tksoft.com <tjk@tksoft.com>
2001-02-23 18:39 ` Jie Liang <jliang@ipinc.com>
2001-02-23 18:44 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox