From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | rodgerd(at)diaspora(dot)gen(dot)nz |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Regular expression query |
Date: | 2000-08-25 04:22:35 |
Message-ID: | 825.967177355@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
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 ...
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Alexandru COSTIN | 2000-08-25 06:12:07 | Re: Re: [GENERAL] Getting the result of a query using COUNT(*) |
Previous Message | Tom Lane | 2000-08-25 03:57:37 | Re: Getting the result of a query using COUNT(*) |