X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 67538329D8A for ; Wed, 8 Sep 2004 19:12:28 +0100 (BST) 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 81029-01 for ; Wed, 8 Sep 2004 18:11:58 +0000 (GMT) Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net [194.217.242.88]) by svr1.postgresql.org (Postfix) with ESMTP id E4AA5329D4D for ; Wed, 8 Sep 2004 19:11:57 +0100 (BST) Received: from lfix.demon.co.uk ([80.177.205.209] helo=cerberus.lfix.co.uk) by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) id 1C56vC-000BXL-0U; Wed, 08 Sep 2004 18:11:54 +0000 Received: from linda.lfix.co.uk ([192.168.1.1]) by cerberus.lfix.co.uk with esmtp (Exim 4.34) id 1C56v9-0002gG-BB; Wed, 08 Sep 2004 19:11:51 +0100 Subject: Re: Isnumeric function? From: Oliver Elphick Reply-To: olly@lfix.co.uk To: Josh Berkus Cc: Theo Galanakis , pgsql-sql@postgresql.org In-Reply-To: <200409081048.01034.josh@agliodbs.com> References: <82E30406384FFB44AFD1012BAB230B55037D056E@shiva.au.lpint.net> <200409080947.17682.josh@agliodbs.com> <1094664017.2014.80.camel@linda> <200409081048.01034.josh@agliodbs.com> Content-Type: text/plain Organization: LFIX Limited Message-Id: <1094667111.2014.98.camel@linda> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Wed, 08 Sep 2004 19:11:51 +0100 Content-Transfer-Encoding: 7bit X-LFIX-MailScanner: Found to be clean X-MailScanner-From: olly@lfix.co.uk X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/50 X-Sequence-Number: 18896 On Wed, 2004-09-08 at 18:48, Josh Berkus wrote: > Theo, Oliver, > > > Any reason why you don't like ~ '^([0-9]?)+\.?[0-9]*$' ? > > Yes, because it also matches "." , which is not a valid numeric value. > > > ~ '^([0-9]+|[0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+)$' > > Ah, the brute force approach ;-) Nothing like using a nice big hammer! > Actually, the above could be written: > > ~ '^([0-9]+)|([0-9]*\\.[0-9]+)$' But that doesn't allow a trailing decimal point. > > ... though that still seems inelegant to me. Is there a regex expert in the > house? All the elegant approaches I can think of match the empty string. There must be at least one digit and 0 or 1 decimal point with no other characters permitted. If you use this as a constraint, you could make it elegant and combine it with another constraint to exclude '' and '.'. -- Oliver Elphick olly@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA ======================================== "Put on the whole armor of God, that ye may be able to stand against the wiles of the devil." Ephesians 6:11