12-Hour Time with AM/PM
beginnerMatches time in 12-hour format with AM/PM indicator.
time12hourampmformat
Pattern
/(?:1[0-2]|0?[1-9]):[0-5]\d\s?[AaPp][Mm]/gTry It
0 of 7 strings matched
Explanation
Matches hours 1-12 (with optional leading zero), minutes 00-59, optional space, and AM/PM indicator (case-insensitive).
Test Strings
Matching
- 9:30 AM
- 12:00PM
- 01:45 pm
- 11:59 AM
Non-matching
- noon
- 99:99
- midnight
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /(?:1[0-2]|0?[1-9]):[0-5]\d\s?[AaPp][Mm]/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);