-3

I'm looking for a regex to match decimal numbers only, but to fail on integers.

For example, the following numbers should pass

0.00
1.00
-1.00
3.3
2.22123

But the following should fail

-1
-3
4
559

I don't know why this is so hard to find/create, but I'm not having any luck. All available regexes that I found online don't exclude integers.

Nick Mullen
  • 107
  • 2
  • 10
  • Maybe: `^-?\d+\.\d+$` – JvdV Feb 19 '20 at 16:13
  • What have you tried? What didn't work? What did you get? What did you expect? What doesn't work with your code and where is it? – Toto Feb 19 '20 at 16:42
  • You closed the question and added a related to a question that specifically asks for something else (matching floating point numbers AND integers, whereas my question wants to exclude integers) – Nick Mullen Feb 25 '20 at 17:04

2 Answers2

0

\d+\.\d+?$ this pattern should work

Gene Sy
  • 1,325
  • 2
  • 10
  • 17
0

This pattern works regexr.com/4ulml

^[-]?\d+\.\d+$
Sami Farhat
  • 1,164
  • 8
  • 12