Re: UNICODE and regex character classes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Norris <danorris(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: UNICODE and regex character classes
Date: 2004-08-05 02:39:32
Message-ID: 13316.1091673572@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

David Norris <danorris(at)gmail(dot)com> writes:
> So I tried this regular expression:
> "^[[:alpha:]][[:alpha:][:digit:]_]{2,}$". But :alpha: only matches
> "pure" ASCII alphabetics, and [:digit:] only matches ASCII '0' thru
> '9'. Is there another named class I can use for this, like
> [:unicodealpha:]? If not, what's the best way to achieve this?

The regex character classes really ought to be encoding- and
locale-aware. Right now they are not, but possibly something
similar to what I recently did to the upper/lower/initcap functions
would work --- that is, rely on the <wctype.h> C library instead of
<ctype.h>. If you feel like working on this, the regex stubs are
in src/backend/regex/regc_locale.c, and the upper/lower change
is in src/backend/utils/adt/oracle_compat.c:
http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/utils/adt/oracle_compat.c.diff?f=h&r1=text&tr1=1.50&r2=text&tr2=1.53

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Benjamin 2004-08-05 05:39:48 lock entire database
Previous Message David Norris 2004-08-05 01:24:05 Re: UNICODE and regex character classes