Regular expression for validating numbers

Lesson 1: An Introduction, and the ABCs Lesson 1½: The 123s Lesson 2: The Dot Lesson 3: Matching specific characters Lesson 4: Excluding specific characters Lesson 5: Character ranges Lesson 6: Catching some zzz's Lesson 7: Mr. Kleene Lesson 8: Characters optional Lesson 9: All this whitespace Lesson 10: Starting and ending Lesson 11: Match groups Lesson 12: Nested groups Lesson 13: More group work Lesson 14: It's all conditional Lesson 15: Other special characters Lesson X: Infinity and beyond!Problem 1: Matching a decimal numbers Problem 2: Matching phone numbers Problem 3: Matching emails Problem 4: Matching HTML Problem 5: Matching specific filenames Problem 6: Trimming whitespace from start and end of line Problem 7: Extracting information from a log file Problem 8: Parsing and extracting data from a URL Problem X: Infinity and beyond!The following three different formats are demonstrated The first regular expression allows one or more characters in the set [0-9] preceded or followed by any number of spaces within the length of the string.

A number with leading and trailing spaces can be considered valid because conversion to numeric data will ignore the spaces.

However, it is a good idea to trim data before validating using alltrim covered previously.

The expressions again follow the pattern set forth in the previous examples.

These differ only in the addition of test, (\.\d ) for a decimal point and decimals.

The second regular expression is nearly the same as the first with one difference.

It not only allows leaving off the cents, but will accept part of a decimal: the decimal point followed by zero, one, or two digits.

These were, however, still strings since the results of any mathimatical operation using them is meaningless. Numerical data is alway handled as string representations of numbers in (X)HTML forms or when the data is sent to the server.

This allows some string based tests to verify that the string's pattern matches acceptable numeric data. Said another way: only an unsigned (positive) whole number.

Hello, I'm trying add some validation to an integer field. I've found a regex example that works, but only for numbers 1-999.

var reg Ex Test = /^[1-9][0-9]*$/; g_Field Msg("u_regex_test", true); if(!

NOTE: the if a decimal point is present it must be followed by at least one digit in each example.