X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id C09749FB254 for ; Fri, 7 Jul 2006 18:33:08 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 95854-02 for ; Fri, 7 Jul 2006 18:33:05 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web31803.mail.mud.yahoo.com (web31803.mail.mud.yahoo.com [68.142.207.66]) by postgresql.org (Postfix) with SMTP id 2E2399FB252 for ; Fri, 7 Jul 2006 18:33:04 -0300 (ADT) Received: (qmail 36134 invoked by uid 60001); 7 Jul 2006 21:33:01 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=JlQXzr67DPH6qwUHPWqtnYVTfU3ZRgtZFNdt9bEla485gi2I9ZLNoyrpL2Uo779SCkRpcvkzFoSMJhdYYUpgQuZqUC+5zLWjltXC66iVMNbmhXZoEeHhbTum7d2IXuct0Vw5Fx3H8aEWEBMhQ00nVzozYCPsvTmV/AR3dJxQ7BU= ; Message-ID: <20060707213301.36130.qmail@web31803.mail.mud.yahoo.com> Received: from [65.211.203.119] by web31803.mail.mud.yahoo.com via HTTP; Fri, 07 Jul 2006 14:33:01 PDT Date: Fri, 7 Jul 2006 14:33:01 -0700 (PDT) From: Richard Broersma Jr Subject: Re: SELECT substring with regex To: mailreg@numerixtechnology.de, pgsql-sql@postgresql.org In-Reply-To: <44AEC8C5.80103@numerixtechnology.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/122 X-Sequence-Number: 25696 > valid entries would be: > "28mm F2.8" (prime lens) > "30-70mm F4" (zoom lens) > "30-70mm F2.8" (zoom lens) > "30-100mm F4.5-5.6" (zoom lens with variable speed) > > > In the WHERE clause I have specified all those NAMEs, which follow that > pattern but have some gubbins appended: > > WHERE NAME ~ > '^((\\d+(-\\d+)?)mm F((\\d+(\.\\d+)?)+(\.(\\d+(\.\\d+)?)+)?))\\D+$' > > > which gives me a listing of those candidates that need to be amended - > manually or otherwise. > > Next, I wanted to produce a result which splits NAME into what it should > be (BASE) and attributes (SUFFIX). Maybe I can generate some SQL from > that to tidy up the data. would this give you the results you want? It admit that it doesn't look to elegant. name: substr(your_string, 0, strpos(your_string, ' ')+1) suffix: substr(your_string, length(your_string)-strpos(your_string, ' '), length(your_string)) Regards, Richard Broersma Jr.