From: | Stuart Peters <s(dot)peters(at)surrey(dot)ac(dot)uk> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Regular expression not working [^xyz] |
Date: | 2000-10-02 17:15:03 |
Message-ID: | v04220809b5fe6b4bafd3@[131.227.9.109] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
I wasn't aware that Postgres accepted regular expressions (they seem
undocumented) until reading the draft of Bruce Momjian's forthcoming
book. However, now having looked at them, I have found a bug in
matching a particular expression from a PostgreSQL database. I am
using:
PostgreSQL 7.0.2 on sparc-sun-solaris2.7, compiled by gcc 2.8.1
I have created a very brief table ('bug') that has one 'text' field
('title') and three records:
\connect - postgres
CREATE TABLE "bug" (
"title" text
);
COPY "bug" FROM stdin;
abcdefghijklm
nopqrstuvwxyz
aeiou
\.
The following queries work as expected, EXCEPT for [2]. I believe
that [2] and [3] should return identical results, but [2] simply
lists ALL titles:
[1] select title from bug where title ~* '[ae]';
Lists titles that contain one of the letters a or e: WORKS
[2] select title from bug where title ~* '[^ae]';
Lists ALL titles rather than those that don't contain a or e:
DOESN'T WORK
(Note: 'select title from bug where title ~* '[^a];' does not work either
[3] select title from bug where title !~* '[ae]';
Lists all titles that don't contain a, q, x or z: WORKS
[4] select title from bug where title ~* '^[^ae]';
Lists all titles that do not begin with a, q, x or z: WORKS
I hope this helps with development,
Regards,
Stuart Peters
____________________________________________________________________________
Stuart Peters, Dept of Sociology, University of Surrey, Guildford GU2 7XH,
United Kingdom. Tel: +44 (0)1483 259292 Fax: +44 (0)1483 259551
Electronic Publishing Resource Service - EPRESS http://www.epress.ac.uk/
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2000-10-02 17:32:54 | Re: grant/revoke bug with delete/update |
Previous Message | Peter Eisentraut | 2000-10-01 20:49:51 | Re: grant/revoke bug with delete/update |