I have users who are pasting strings into text fields that break my calculations. I could really use some help building a Regex expression that:
- only allows numbers 0-9
- only allows one "-" (ascii 45) in the first position in the string
- only allows one "." (ascii 46)
- only allows for up to 3 decimal places after the only instance of "." (ascii 46)
2
Answers
This should work:
/^-?d{1,}.?d{0,3}$/
should be working.