I keep getting into situations where I end up making two regular expressions to find subtle changes (such as one script for 0-9 and another for 10-99 because of the extra number)
I usually use [0-9] to find strings with just one digit and then [0-9][0-9] to find strings with multiple digits, is there a better wildcard for this?
ex. what expression would I use to simultaneously find the strings
6:45 AM and 10:52 PM
You can specify repetition with curly braces.
[0-9]{2,5}matches two to five digits. So you could use[0-9]{1,2}to match one or two.[0-9]{1,2}:[0-9]{2} (AM|PM)I personally prefer to use
\dfor digits, thus\d{1,2}:\d{2} (AM|PM)