tool::regex-guide
regex number
/^-?\d+(\.\d+)?$/
Number (Integer / Decimal) Validation
Regex Pattern
/^-?\d+(\.\d+)?$/
Flags:
nonePattern Breakdown
^Start of string-?Optional minus sign (for negative numbers)\d+One or more digits (integer part)(\.\d+)?Optional decimal point and digits$End of stringMatching Examples
✓
42✓
-7✓
3.14✓
-0.001Non-Matching Examples
✗
3.14.15✗
1,000✗
NaN✗
1e10Validates both integers and decimal numbers including negative values. Composed of an optional minus sign, integer part, and optional decimal part. Numbers with commas (1,000) or exponential notation (1e10) require separate patterns.
Language Usage
Common Use Cases
- ▸Validate price or amount input fields
- ▸Check coordinate data format (latitude, longitude)
- ▸Parse input for math calculators
- ▸Validate numeric values in config files
- ▸Clean numeric columns in CSV files
Related Patterns
ad · 300×250
// related tools