What’s a better regex pattern for validating floats?

0
2
Asked By Keven Krok On

I'm trying to improve my regex for identifying floating-point numbers. Currently, I'm using this regex: `^-?(d+.d*|d*.d+)$`. It successfully matches values like `-90.`, `.67`, and `42.6`, but it doesn't accept just `.` or `-`. I want to ensure there's at least one digit present before or after the decimal point. Any suggestions for a better or more efficient regex?

0 Answers

There is no answer to this question yet. If you know the answer or can offer some help, please use the form below.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.