# Category Archives: Numbers

Useful regular expressions to match numbers like telephone numbers, credit card numbers, etc.

## Positive Decimal Regular Expression

A regular expression to match a positive decimal value.

`/(^\d*\.?\d*[0-9]+\d*\$)|(^[0-9]+\d*\.\d*\$)/`

## Positive Integer Regular Expression

A regular expression to match a positive integer value like 10, 20, 100, etc.

`/^\d+\$/`

## Regular Expression For Formatted Number With Space As Thousand Separator

A Regular Expression for those who use a space as thousands separator.

`/(^(((\d)|(\d\d)|(\d\d\d))(\xA0|\x20))*((\d)|(\d\d)|(\d\d\d))([,.]\d*)?\$)/`

## Regular Expression To Validate A Percentage From 0 To 100

A Regular Expression to validate a percentage from 0 to 100.

`/^(0*100{1,1}\.?((?<=\.)0*)?%?\$)|(^0*\d{0,2}\.?((?<=\.)\d*)?%?)\$/`

## Regular Expression To Check If Number Is Float

A Regular Expression to check if the number you provide is a float value.

`/^[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?\$/`

## Currency Regular Expressions

A set of regular expressions that helps you validate and parse Money/Currency/Price values.

`/^-?\d+(,\d{3})*(\.\d{1,2})?\$/`

## Phone Number Regular Expressions

A collection of useful Regular Expressions to parse, validate, and format phone numbers around the world.

`/^\\(?([0-9]{3})\\)?[-.\\s]?([0-9]{3})[-.\\s]?([0-9]{4})\$/`

## Regular Expression For US Postal Codes

A regular expression to match and valid US.S five-digit and nine-digit (zip+4) postal codes.

`/^\d{5}(?:[-\s]\d{4})?\$/`

## Regular Expressions For 4 Or 6 Digits

Regular Expressions that exactly match 4 or 6 digits, which are typically used in Pin Code.

`/^[0-9]{4}\$/`

## Regular Expression For Year

A regular expression to match and validate a 4-digit year (from 1900 to 2099).

`/^(19|20)[\d]{2,2}\$/`