Received: from mail1.hub.org (webmail.hub.org [216.126.85.1]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f8KAFZe86384 for ; Thu, 20 Sep 2001 06:15:35 -0400 (EDT) (envelope-from news@news.tht.net) Received: from news.tht.net (news.hub.org [216.126.91.242]) by mail1.hub.org (8.11.3/8.11.4) with ESMTP id f8KA3dD79642 for ; Thu, 20 Sep 2001 06:03:39 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id f8K9ZqN21120 for pgsql-sql@postgresql.org; Thu, 20 Sep 2001 05:35:52 -0400 (EDT) (envelope-from news) From: rdear X-Newsgroups: comp.databases.postgresql.sql Subject: Re: PL/PGSQL Regexe Date: Thu, 20 Sep 2001 10:45:30 +0100 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 74 Message-ID: <3BA9BABA.5030407@dev.internal> References: <28279.1000909202@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------030201090706020507060602" X-Complaints-To: scrappy@hub.org User-Agent: Mozilla/5.0 (X11; U; Linux 2.2.16-22 i686; en-US; m18) Gecko/20010131 Netscape6/6.01 X-Accept-Language: en To: pgsql-sql@postgresql.org X-Archive-Number: 200109/249 X-Sequence-Number: 4931 --------------030201090706020507060602 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Humm... 7.0.2, I'll upgrade and try again. Thanks! Tom Lane wrote: > rdear writes: > >> I'm doing a check within a PL/PGSQL function using a regular expression >> and I get the error: > >> ERROR: regcomp failed with error invalid character range > >> This appears to be because of the underscore "_" character. The regex I >> want to use is ''[A-Za-z0-9_]'' but this doesn't work. > > > Seems to work for me: > > regression=# select 'a' ~ '[A-Za-z0-9_]'; > ?column? > ---------- > t > (1 row) > > regression=# select '_' ~ '[A-Za-z0-9_]'; > ?column? > ---------- > t > (1 row) > > regression=# select ':' ~ '[A-Za-z0-9_]'; > ?column? > ---------- > f > (1 row) > > How old is your Postgres? (I can tell by the spelling of the error > message that it's not current.) > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) --------------030201090706020507060602 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Humm... 7.0.2, I'll upgrade and try again.

Thanks!


Tom Lane wrote:
rdear <rdear@dev.internal> writes:
I'm doing a check within a PL/PGSQL function using a regular expression 
and I get the error:
ERROR:  regcomp failed with error invalid character range
This appears to be because of the underscore "_" character. The regex I 
want to use is ''[A-Za-z0-9_]'' but this doesn't work.

Seems to work for me:

regression=# select 'a' ~ '[A-Za-z0-9_]';
?column?
----------
t
(1 row)

regression=# select '_' ~ '[A-Za-z0-9_]';
?column?
----------
t
(1 row)

regression=# select ':' ~ '[A-Za-z0-9_]';
?column?
----------
f
(1 row)

How old is your Postgres? (I can tell by the spelling of the error
message that it's not current.)

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

--------------030201090706020507060602--