From: Michael Fuhr <mike@fuhr.org>
To: Aldor <an@mediaroot.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: POSIX Regular Expression question
Date: Mon, 5 Sep 2005 08:15:45 -0600
Message-ID: <20050905141545.GA20793@winnie.fuhr.org> (raw)
In-Reply-To: <431C4EB2.80401@mediaroot.de>
References: <431C4EB2.80401@mediaroot.de>
On Mon, Sep 05, 2005 at 02:57:06PM +0100, Aldor wrote:
>
> I want to get out a string only with characters A-Za-z.
>
> I tried really a lot of things with substring and read many POSIX docs,
> I'm also familiar with the Perl RegEx but right now, I'm giving up... ;-(
>
> Any idea how to do this in Postgres with POSIX Regex?
Match the beginning of the string with ^.
Match one or more characters in the set A-Za-z with [A-Za-z]+ (or
with just [A-Z]+ or [a-z]+ if you're doing a case-insensitive match).
Using [[:alpha:]]+ should also work.
Match the end of the string with $.
Examples:
SELECT 'abcd' ~ '^[A-Za-z]+$';
?column?
----------
t
(1 row)
SELECT 'ABCD' ~* '^[a-z]+$';
?column?
----------
t
(1 row)
SELECT 'ABC123' ~* '^[a-z]+$';
?column?
----------
f
(1 row)
--
Michael Fuhr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mike@fuhr.org, an@mediaroot.de
Subject: Re: POSIX Regular Expression question
In-Reply-To: <20050905141545.GA20793@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox