RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
(^\d*\.?\d*[0-9]+\d*$)|(^[0-9]+\d*\.\d*$)
Description
This matches all positive decimal values. There was one here already which claimed to but would fail on value 0.00 which is positive AFAIK...
Matches
0.00 | 1.23 | 4.56
Non-Matches
-1.03 | -0.01 | -0.00
Author Rating: The rating for this expression. Derek Noonan
Source Adapted from one already here
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Matches .1
Name: Vera Rindvieh
Date: 5/27/2015 4:26:19 AM
Comment:
The regex matches ".1" that looks stange. What about: ^\d+(\.\d+)?$ If anyone needs sign information: ^[+-]?\d+(\.\d+)?$ will do the job.


Title: Matches .1
Name: Vera Rindvieh
Date: 5/27/2015 4:26:09 AM
Comment:
The regex matches ".1" that looks stange. What about: ^\d+(\.\d+)?$ If anyone needs sign information: ^[+-]?\d+(\.\d+)?$ will do the job.


Title: regular expression
Name: madhumita
Date: 4/6/2015 5:20:49 AM
Comment:
Regular expression is very useful. Thank you.


Title: Derek's can easily accomodate negative numbers
Name: Doreen
Date: 11/21/2014 7:05:43 PM
Comment:
I altered yours a bit to allow for negative entries: (^(-)?\d*\.?\d*[0-9]+\d*$)|(^[0-9]+\d*\.\d*$) I tried many other expressions that allow negative entries in addition to other fancy things but I liked your cleaner approach here. Thank you.


Title: Derek's positive expression
Name: Happy Jack
Date: 6/13/2005 10:18:45 PM
Comment:
This was very helpful. Now I have the validation I need.


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials