Here's the pattern I'm working on:
var re = /(\d{1,2}\.(?=\d{1,2}))/;
What I would like for this to return is a one or two digit number (which will never be greater than 24, since it is for a time mgmt app), which may or may not be followed by a decimal point with either one or two trailing digits, but not more than two.
I'm not sure about the parenthetical substring match mixed with the lookahead. I just guessed and nested them. Ultimately, if my syntax is okay, I think the only thing I am missing is how to suggest that the pattern may or may not have leading digits, and may or may not contain a decimal with trialing digits.
Let me know if you need more info.
Update, Examples:
We are only dealing with time, and no more time than can occur in a single day. 24 would be the highest input.
Valid:
23.75
1.4
1
0.5
0
.2
Invalid:
1.897
%#$#@$#
Words
other characters
Newest Update:
Since this is a decimal, 23.75 works. We are not counting minutes, but rather fractions of hours.
Also, for the record, I tried validating using methods and conditionals, and it was letting letters pass through after the decimals. I have made the decision to go with regex.