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

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details Number limiting x digits before decimal, and y digits after decimal point.
Expression
^([0-9]{0,5}|[0-9]{0,5}\.[0-9]{0,3})$
Description
This regular expression is intended to limit numeric entries by allowed places before and after the decimal point. It also recognizes whole numbers. In this example the value cannot exceed 99999.999. To change the range, simply edit the numbers in curly braces. For example, to allow 7 digits (millions) before the decimal point, change both instances of {0,5} to {0,7}. Likewise, to change the decimals from allowing thousandths (3 digits) to just hundreths, change the {0,3} to {0,2}. This can be useful for numeric fields in SQL. This example was made to accommodate a numeric(8,3) field definition.
Matches
0 | 1 | 1.55 | 54321.123 | .12
Non-Matches
abc | 654321 | 12..34 | .1234
Author Rating: Not yet rated. Ken Palmer
   Displaying page 1 of 1 pages; Items 1 to 1

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