[GENERAL] Regex problems

From: Charles Curley <charles(dot)h(dot)curley(at)lmco(dot)com>
To: PostgreSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: [GENERAL] Regex problems
Date: 1998-10-06 19:09:05
Message-ID: 361A6AD0.67E70985@lmco.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm running 6.3.2 on RedHat 5.0. I have the following table:

Table = employees
+---------------------+----------------------------------+-------+
| Field | Type | Length|
+---------------------+----------------------------------+-------+
| id | char() not null | 8 |
| first | char() | 20 |
| mi | char() | 1 |
| last | char() | 20 |
| suffix | char() | 8 |
| dept | char() | 8 |
| phone | char() | 20 |
| mp | char() | 8 |
| email | char() | 64 |
+---------------------+----------------------------------+-------+

If I do the following:

select "dept", "last", "first" from "employees" where "last" = 'Curley';

I get my information. If I do:

select "dept", "last", "first" from "employees" where "last" ~ 'C*';

I get the entire table's worth of matches (883) regardless of what the
last name is. Examples that are matched:

dept |last |first
--------+--------------------+-------
A5A0 |Achey |Karen
A5M2 |Achey |Lonny
A75P |Ackley |Roger
A847 |Adair |Ethel
A84P |Adams |Denise
A654 |Adams |Gary
...
A847 |Young |Ronald
A75P |Younger |Curtis
A847 |Zappia |Sandy
A850 |Zrinski |Beverly
A5MP |Zygmant |Michael
(883 rows)

Trying the following:

select "dept", "last", "first" from "employees" where "last" ~ 'Cu*';

Produces fewer hits (74) but gives wrong values again, basically
returning all the employees with a last name that begins with 'C' as
well a few strange matches at the end with "last" values of 'Del
Castillo', 'Moore', and 'O''Connor'.

Telling me to use LIKE isn't what I'm hoping to get here. My searches
will require that I use regular expressions, I just toned them down for
the examples.

--
Charles Curley, Staff Engineer
Computer Integrated Manufacturing
Lockheed Martin Ocala Operations

Responses

Browse pgsql-general by date

  From Date Subject
Next Message chris yambo 1998-10-06 19:23:31 Re: [GENERAL] Regex problems
Previous Message Andrea Antibo 1998-10-06 16:50:32 Re: [GENERAL] make[2]: *** [psql] Error 1