Re: question about reg. expression

From: Samuel Gendler <sgendler(at)ideasculptor(dot)com>
To: andrew1 <andrew1(at)mytrashmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: question about reg. expression
Date: 2011-01-19 10:21:07
Message-ID: AANLkTi=guS5T46M5wt7VXH8_0SfZ-_D+uG6Y=68FAFWJ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I'd think you need to indicate multiple alphabetic matches. Your first
regex actually matches only b followed by end of string and the second is
really only matching start of string followed by a. The third is looking
for a single character string.

Try this: select 'ab' ~ '^[a-z]+$'
or this: select 'ab' ~ '^[a-z]*$'

or if looking only for 2 character strings: select 'ab' ~ '^[a-z][a-z]$'

On Tue, Jan 18, 2011 at 3:41 PM, andrew1 <andrew1(at)mytrashmail(dot)com> wrote:

> hi all,
>
> these return t:
> select 'ab' ~ '[a-z]$'
> select 'ab' ~ '^[a-z]'
>
> select 'ab' ~ '^[a-z]$' returns f
>
> Can't I use ^ and $ at the same time to match, in this case?
> thanks.
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stephen Belcher 2011-01-19 13:17:50 Re: question about reg. expression
Previous Message andrew1 2011-01-18 23:41:20 question about reg. expression