-1

I want to built a calculator which accepts numbers like 1E100 or 1.34E-200. In order to check if the number entered is acceptable i decided to test the condition with my regex:

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

however i get an illegal escape and i dont know why? does reges not accept my E?

Jin
  • 7
  • 2

1 Answers1

-1

You escaped the E, which is not necessary :

^(-?\d+\.?\d*E?\-?\d*)$

Test it here

totok
  • 1,436
  • 9
  • 28