Re: Isnumeric function? - Mailing list pgsql-sql

From Thomas Swan
Subject Re: Isnumeric function?
Date
Msg-id 413FB8C0.4050008@idigx.com
Whole thread Raw
In response to Re: Isnumeric function?  (Oliver Elphick <olly@lfix.co.uk>)
Responses Re: Isnumeric function?
List pgsql-sql
Oliver Elphick wrote:

>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!
>
>  
>
Would "^([0-9]+\\.{0,1}[0-9]*|\\.[0-9]+)$" be a little cleaner?

>>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 '.'.
>  
>



pgsql-sql by date:

Previous
From: Terence Kearns
Date:
Subject: check for circular references in a 2-table heirachy
Next
From: Greg Stark
Date:
Subject: Re: Isnumeric function?