Skip site navigation (1) Skip section navigation (2)

Re: Regular expression query

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: rodgerd(at)diaspora(dot)gen(dot)nz, pgsql-sql(at)postgresql(dot)org
Subject: Re: Regular expression query
Date: 2000-10-15 18:50:46
Message-ID: 200010151850.OAA11290@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-sql
> Rodger Donaldson <rodgerd(at)diaspora(dot)gen(dot)nz> writes:
> > SELECT url 
> > FROM sites
> > WHERE url ~ url || '\\s+'
> 
> > While this concatenation works with the LIKE directive (ie LIKE url || '%'),
> > postgresql barfs on it in a regexp with the error:
> 
> > ERROR:  Unable to identify an operator '||' for types 'bool' and 'unknown'
> > 	You will have to retype this query using an explicit cast
> 
> LIKE and ~ do not have the same precedence.  See
> http://www.postgresql.org/docs/postgres/operators.htm.
> ~ and || actually fall in the same category ("all other") and therefore
> are grouped left-to-right; so you're getting (url ~ url) || '...'.
> 
> > The other aspect of this is that it seems that postgresql's regexp engine
> > doesn't understand some expected regexps; I've tried both escaped and
> > unescaped versions of, eg \w, \s, \n and so on a pg seems to ignore them.
> 
> The regexp package we currently use implements POSIX 1003.2 regexps
> (see src/backend/regex/re_format.7).  I believe there is an item on the
> TODO list about upgrading the regexp parser to something more modern
> ... feel free to hop on that project if it's bugging you ...

I bug Henry Spencer regularly.  His new code is in TCL/TK, but has not
been released into any other code.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

In response to

pgsql-sql by date

Next:From: Tom LaneDate: 2000-10-15 20:26:24
Subject: Re: Variable-length Types
Previous:From: Josh BerkusDate: 2000-10-15 18:31:40
Subject: Re: Variable-length Types

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group