Regex for any number of digits, but only one decimal?

View: New views
5 Messages — Rating Filter:   Alert me  

Regex for any number of digits, but only one decimal?

by Ian Skinner-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Any suggestions on how one would determine that input contains only
numbers and no more then one decimal '.' character.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:1108
Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user837.14401.21




Re: Regex for any number of digits, but only one decimal?

by Ben Doom-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

^\d+\.\d+$

I'm assuming you want digits before and after the decimal.

--Ben Doom

Ian Skinner wrote:
> Any suggestions on how one would determine that input contains only
> numbers and no more then one decimal '.' character.
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:1109
Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user837.14401.21



Re: Regex for any number of digits, but only one decimal?

by Ian Skinner-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ben Doom wrote:
> ^\d+\.\d+$
>
> I'm assuming you want digits before and after the decimal.
>
> --Ben Doom
Yes, but either side is optional.  One or the other, but not necessarily
both.

I.E.

..001 = Good
100 = Good
1.1 = Good.
1.1.1 = Bad



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:1110
Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user837.14401.21



Re: Regex for any number of digits, but only one decimal?

by Ian Skinner-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ben Doom wrote:
> ^\d+\.\d+$
>
> I'm assuming you want digits before and after the decimal.
>
> --Ben Doom
The anchors (^,$) are what I needed.  I basically had "d*\.d*"  Adding
the anchors prevents extra decimal '.' characters.

Thanks.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:1111
Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user837.14401.21



Re: Regex for any number of digits, but only one decimal?

by Ben Doom-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This will let both sides be optional.  You may want to try:

^(\d+\.\d*|\.\d+)$

This will allow "3.", which may or may not be what you wanted.

--Ben Doom

Ian Skinner wrote:

> Ben Doom wrote:
>> ^\d+\.\d+$
>>
>> I'm assuming you want digits before and after the decimal.
>>
>> --Ben Doom
> The anchors (^,$) are what I needed.  I basically had "d*\.d*"  Adding
> the anchors prevents extra decimal '.' characters.
>
> Thanks.
>
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:1112
Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user837.14401.21