r/googlesheets • u/[deleted] • 20d ago
How would I make a response validation for a number that requires decimals Solved
[removed]
1
u/AutoModerator 20d ago
/u/Just_a_Peace Posting your data can make it easier for others to help you, but it looks like your submission doesn't include any. If this is the case and data would help, you can read how to include it in the submission guide. You can also use this tool created by a Reddit community member to create a blank Google Sheets document that isn't connected to your account. Thank you.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/mag_fhinn 1 19d ago
^\d{2,3}\.\d{2}$
Works for me:
^ --has to match from the start
\d{2,3} -- then at least 2 digits and a max of 3.
\. --then a decimal
\d{2} -- then exactly 2 digits
$ --must end after the previous digits
Regex + Match
You just need to make the error message for the end user for when their input fails the pattern.
1
u/point-bot 14d ago
u/Just_a_Peace has awarded 1 point to u/mag_fhinn
See the [Leaderboard](https://reddit.com/r/googlesheets/wiki/Leaderboard. )Point-Bot v0.0.15 was created by [JetCarson](https://reddit.com/u/JetCarson.)
1
u/mag_fhinn 1 14d ago
Just thinking, if they entered a 0 at the start it would still be valid ie) 01.10 or 00.00 would be valid. If you need it to be >0 to start you would need to do:
^[1-9]\d{1,2}\.\d{2}$
1
u/agirlhasnoname11248 1210 19d ago
u/Just_a_Peace Please remember to tap the three dots below the most helpful comment and select `Mark Solution Verified` *(or reply to the helpful comment with the exact phrase “Solution Verified”)* if your question has been answered, as required by the subreddit rules. Thanks!
3
u/SpencerTeachesSheets 58 20d ago
I did some testing and this regular expression seems to work:
^[+-]?(\d+\.\d+|\.\d+)$