Title |
Test
Find
Percent Expression
|
Expression |
^\s*(\d{0,2})(\.?(\d*))?\s*\%?\s*$ |
Description |
Basically this matches into variables for percentages.. It allows as much whitespace before and after the expression. $1 = Percent before decimal, $2 = percentage after decimal inc decimal, $3 = percentage after decimal. Disallowed anything past 99.99999 repeating percent. No negative percents either. Easy to implement but I do not need it. |
Matches |
10.5%, 1%, 1, .5, .0555% |
Non-Matches |
100%, -1%, -1, 200, 200.1 |
Author |
Rating:
Not yet rated.
Mike Willbanks
|
Source |
|
Your Rating |
|
Title: Better variant
Name: Nikolay Sonin
Date: 4/10/2009 4:43:49 PM
Comment:
^\s*((-){0,1}(\d{0,})(\.?(\d*)))?\s*\%?\s*$
This variant can also work with negative and big (> 100) percents
Title: Percent Expression issues
Name: Daniel
Date: 9/12/2006 4:13:16 PM
Comment:
It looks good at first but there are a few big holes in this one. These entries are allowed: 56323, %. Aside from that the unlimited whitespace between the number and the percent sign seems unnecessary and it would be nice to allow any percentile including 100% exactly.