X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6713ED7DBE for ; Wed, 5 Oct 2005 02:56:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07623-09 for ; Wed, 5 Oct 2005 05:56:09 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id CCD28D6F63 for ; Wed, 5 Oct 2005 02:56:08 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j955u65W074336 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 4 Oct 2005 23:56:08 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j955u6ki053864; Tue, 4 Oct 2005 23:56:06 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j955u5rP053863; Tue, 4 Oct 2005 23:56:05 -0600 (MDT) (envelope-from mfuhr) Date: Tue, 4 Oct 2005 23:56:05 -0600 From: Michael Fuhr To: gurkan@resolution.com Cc: pgsql-sql@postgresql.org Subject: Re: regular expression Message-ID: <20051005055605.GA53834@winnie.fuhr.org> References: <1128377310.4341abde55776@www.resolution.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1128377310.4341abde55776@www.resolution.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200510/26 X-Sequence-Number: 22879 On Mon, Oct 03, 2005 at 06:08:30PM -0400, gurkan@resolution.com wrote: > How do I do regular expression for the problem that I am having > I have a string called desc, and say that this string in > > "TSWUU" ------ "" > "4 - DSC" ------ "4" > "6768 - THY" ------ "6768" > > basically string may or may not start with number, > I need substring of digits parts > "" > "4" > "6768" See "Pattern Matching" in the documentation: http://www.postgresql.org/docs/8.0/interactive/functions-matching.html Example: test=> SELECT id, data FROM foo; id | data ----+------------ 1 | TSWUU 2 | 4 - DSC 3 | 6768 - THY (3 rows) test=> SELECT id, substring(data FROM '^([[:digit:]]+)') FROM foo; id | substring ----+----------- 1 | 2 | 4 3 | 6768 (3 rows) -- Michael Fuhr