Regular Expressions - Example 3

This example gives a few "standard" regular expressions and allows you to test each one against an input string.


Regular expression Description Does it match your input?
/\S/ Non-blank string
/^\s*\d+\s*$/ Whole number (digits only)
/^[0-9]$/ Single digit
/^\s*(\+|-)?\d+\s*$/ Whole number with optional + or - sign
/^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/ Decimal number
/^#([0-9a-fA-F])+$/ Hexadecimal number