I’m looking for regex that will match “a”,”p”,” a”,” p”,”am”,”pm”,” am”,” pm”.
Note that what I’m looking for is whitespace agnostic. I have a regex grouping within a string, what I have right now, that is not working for a/m/am/pm is this:
/^(\d{1,2}):(\d{2})(\s(am|pm|a|p)$)/i;
The main change is the asterisk (
*) after\s. It means – allow any number of whitespaces, or no whitespaces.