Re: [GENERAL] Regex problems

From: "James Oden" <joden(at)lee(dot)k12(dot)nc(dot)us>
To: "Charles Curley" <charles(dot)h(dot)curley(at)lmco(dot)com>, "PostgreSQL Mailing List" <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] Regex problems
Date: 1998-10-07 11:25:49
Message-ID: 005401bdf1e5$3d5f4320$01cc0cac@Yehudah.lee.k12.nc.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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:

The answer is you need to use the meta character that tells the regx engine to look at only the begining of the string for a match. That is your regular expression should be:

"^C"

or

"^C*"

which yields a query like:

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

Adding the 'u' is not a bad idea if you want to get only the last names that start with "Cu".

...james

Browse pgsql-general by date

  From Date Subject
Next Message Sferacarta Software 1998-10-07 13:30:38 Re: [GENERAL] Default 'timestamp' value on HP-UX running Postgresql6.3.2
Previous Message Aharon Al Schkolnik 1998-10-07 11:03:53 Up-to-date PostgreSQL User's Guide - Postscipt ?