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 F0AFC9FB1D9 for ; Fri, 7 Jul 2006 15:37:18 -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 48860-08 for ; Fri, 7 Jul 2006 15:37:11 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.175]) by postgresql.org (Postfix) with ESMTP id E2E2D9FB1B8 for ; Fri, 7 Jul 2006 15:37:10 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id a2so3202232ugf for ; Fri, 07 Jul 2006 11:37:08 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=DdATfplk0bqKVc60l6pik+YyDTIw71f/Z9W+CLzoaJK1dEZCsdgyixTIsn3m8g66AsuKFu+BaCAHoGSgdcyMoHcV6Ua+hXxLxbkJFmK0YZ+D4/OtYBFFm04L18gDSmuc5dxbPJG16UNx5H3bQIJeoyrs30a6f/8YJodF62u7fR0= Received: by 10.67.100.17 with SMTP id c17mr2349999ugm; Fri, 07 Jul 2006 11:37:08 -0700 (PDT) Received: by 10.67.24.20 with HTTP; Fri, 7 Jul 2006 11:37:08 -0700 (PDT) Message-ID: Date: Fri, 7 Jul 2006 13:37:08 -0500 From: "Rodrigo De Leon" To: pgsql-sql@postgresql.org Subject: Re: SELECT substring with regex In-Reply-To: <44AE9B4F.1020401@numerixtechnology.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <44AE66E0.1040606@numerixtechnology.de> <200607071659.14940.gary.stainburn@ringways.co.uk> <44AE9B4F.1020401@numerixtechnology.de> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/110 X-Sequence-Number: 25684 On 7/7/06, T E Schmitz wrote: > But that takes me to the next problem: > > For the sake of the example I simplified the regular pattern. > In reality, BASE_NAME might be: > > 28mm > 28-70mm > > So the reg. expr. requires brackets: > > substring (NAME, '^(\\d+(-\\d+)?mm)' ) as BASE_NAME > > Actually, the pattern is more complex than that and I cannot see how I > can express it without brackets. Maybe: select substring ('150mm LD AD Asp XR Macro', '^[\\d-]*mm' ) as BASE_NAME , substring('150mm LD AD Asp XR Macro','^[\\d-]*mm (.*)$') as SUFFIX; select substring ('28-70mm LD AD Asp XR Macro', '^[\\d-]*mm' ) as BASE_NAME , substring('28-70mm LD AD Asp XR Macro','^[\\d-]*mm (.*)$') as SUFFIX; etc... Regards, Rodrigo