Skip to main content
CalcHive

Regex for Decimal Number

Matches positive and negative decimal numbers with a required fractional part.

Pattern

/^-?\d+\.\d+$/

Pattern Breakdown

TokenExplanation
^Start of string
-?Optional minus sign
\d+One or more digits (whole part)
\.Literal decimal point
\d+One or more digits (fractional part)
$End of string

Test Examples

InputMatch?
3.14Match
-0.5Match
100.00Match
42No match
.5No match

Common Use Cases

  • Price validation
  • Scientific data input
  • Measurement values

Variations

^-?\d*\.?\d+$

Optional decimal point (matches integers too)

Want to test this pattern with your own data?

Open the Regex Tester