Re: Postgres regexp matching failure?

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Postgres regexp matching failure?
Date: 2006-09-05 15:17:22
Message-ID: 20060905151722.GD21195@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Mario Splivalo wrote:
> On Tue, 2006-09-05 at 10:21 -0400, Alvaro Herrera wrote:
> > Mario Splivalo wrote:
> > > On Tue, 2006-09-05 at 08:42 -0500, Aaron Bono wrote:
> > > > On 9/5/06, Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr> wrote:
> > > >
> > > > pulitzer2=# select 'stop works' ~ '^\s*(?:[\
> > > > +|-]|(?:[sS][tT][oO][pP]\b)).*$';
> > > > ?column?
> > > > ----------
> > > > f
> > > > (1 row)
> > > >
> > > > Here, postgres should return true, but it gives me false.
> > > >
> > > >
> > > > \b is a back-space - is that what you are wanting there? If I remove
> > > > it I get true.
> > >
> > > Actually, I'm not sure :) As I've mentioned, python/java/perl do as I
> > > expected, postgres on the other hand doesn't. If \b was the backspace,
> > > then I'd have trouble with '+mario test', and that one seems to be OK.
> >
> > No, because the \b is inside the "stop" arm of the |. You need to do
> > *both*, double backslashes and get rid of \b (or at least understand
> > what you actually mean with it ...)
> >
>
> I know this might not be the right place for this question, but, how
> come (or better: why?) is above regexp macthed ok (ok as in 'the way I
> expected') when employed from java/perl/python?

In Perl at least, \b is a word boundary. In PostgreSQL (and probably
Tcl as well) it's a backslash AFAICT.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2006-09-05 15:22:54 Re: Postgres regexp matching failure?
Previous Message Mario Splivalo 2006-09-05 15:03:53 Re: Postgres regexp matching failure?