Re: Regular expression question with Postgres

From: Mike Christensen <mike(at)kitchenpc(dot)com>
To: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Regular expression question with Postgres
Date: 2014-07-24 20:51:43
Message-ID: CABs1bs0L5kghZKe8B1tT-v2DB9hUMgYFNy082gjkUfEx1ygBWA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yea seems right. I was testing the expression on Rubular (Which uses the
Ruby parser) and it worked. I guess Ruby allows this non-standard
expression with the missing lower bounds. Every reference I could find,
though, agrees only the upper bound is optional.

On Thu, Jul 24, 2014 at 1:42 PM, David G Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> Mike Christensen-2 wrote
> > I'm curious why this query returns 0:
> >
> > SELECT 'AAA' ~ '^A{,4}$'
> >
> > Yet, this query returns 1:
> >
> > SELECT 'AAA' ~ '^A{0,4}$'
> >
> > Is this a bug with the regular expression engine?
>
> Apparently since "{,#}" is not a valid regexp expression the engine simply
> interprets it as a literal and says 'AAA' != 'A{,4}'
>
>
> http://www.postgresql.org/docs/9.3/interactive/functions-matching.html#FUNCTIONS-POSIX-REGEXP
>
> Table 9-13. Regular Expression Quantifiers
>
> Note the all of the { } expressions have a lower bound (whether explicit or
> implied).
>
> David J.
>
>
>
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/Regular-expression-question-with-Postgres-tp5812777p5812778.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2014-07-24 20:57:07 Re: Regular expression question with Postgres
Previous Message David G Johnston 2014-07-24 20:42:16 Re: Regular expression question with Postgres