Regex was-?\d+, which would handle whole numbers, but with division in the mix, you have to handle the possibility of decimals.
The regex became -?\d+(?:\.\d+)?. (?: indicates it's not matching, so we're not grabbing the fractional aspect independently, \.\d_ matches one dot and however many digits, and )? closes the thing and matches only if found, so that it doesn't have to be a floating point number.
And, I see now that I don't handle non-whole-numbers, which the problem doesn't give me, but could come along anyway.
"5 / 4", for example.And that's entirely a regex problem.
Hrm.
Regex was
-?\d+, which would handle whole numbers, but with division in the mix, you have to handle the possibility of decimals.The regex became
-?\d+(?:\.\d+)?.(?:indicates it's not matching, so we're not grabbing the fractional aspect independently,\.\d_matches one dot and however many digits, and)?closes the thing and matches only if found, so that it doesn't have to be a floating point number.