Looking for a Better Regex Pattern for Floats

0
3
Asked By RandomRaccoon42 On

I'm trying to improve my regex for identifying float numbers. Currently, I'm using this pattern: `^-?(d+.d*|d*.d+)$`. This regex checks for digits before and after the decimal point but requires at least one digit to be present. It successfully matches cases like `-90.`, `.67`, and `42.6`, but it fails for just `.` and `-.`. Are there more efficient or clearer regex patterns I can use?

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.