How can I improve my regex for validating floats?

0
2
Asked By Keven Krok On

I'm working on a regex pattern to validate if a string is a float, and I need it to handle cases with digits before and/or after the decimal point while ensuring that at least one digit is present. Currently, I'm using the following regex: `^-?(d+.d*|d*.d+)$`. This matches inputs like `-90.`, `.67`, and `42.6`, but it doesn't match standalone `.` or `-.`. I'm looking for suggestions to refine this regex or alternative methods to achieve robust float validation.

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.