So I made a regex to test valid GPAs such as 0.00 through 5.00 including things like 0, 4, 3.55, etc. Things that aren't valid include 6.0, 3.555, 0.000, 11.11, etc. On multiple websites I have verified that this Regex works for those cases.
(([0-5]\s)|([0-4]\.\d{0,2}\s))|[5]\.[0]{0,2}\s
However then I try and use this in Kotlin using the Java Regex class I'm not getting the expected results, always false for my test cases.
Code with "2.0" test string:
Regex("(([0-5]\\s)|([0-4]\\.\\d{0,2}\\s))|[5]\\.[0]{0,2}\\s").matches("2.0")
I'm curious what I'm missing that is causing this to fail. I've escaped /
characters and tried variations using string literals with no escaping, and also using Pattern/Matcher directly to no avail.