Regex for time (24-hour)
/\b(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?\b/g
Matches
Examples
Note
Requires two-digit hours. Allow 9:05 by changing [01]\d to [01]?\d.
Matches in the example
"09:00""17:30:15"
Token by token
\ba word boundary(?:a group, not capturing[01]one of: “0” or “1”\da digit (0–9)|or2the character “2”[0-3]one of: “0” to “3”)end of group:the character “:”[0-5]one of: “0” to “5”\da digit (0–9)(?:a group, not capturing:the character “:”[0-5]one of: “0” to “5”\da digit (0–9))?end of group, whole group optionally\ba word boundary
Other patterns
- Email address
- URL
- IPv4 address
- UUID
- Hex color
- Date (YYYY-MM-DD)
- Time (24-hour)
- US phone number
- Phone number (E.164)
- US ZIP code
- Credit card number
- URL slug
- Username
- Strong password
- HTML tag
- Semantic version
- MAC address
- JSON Web Token
- Hashtag
- @mention
- Number
- Leading and trailing whitespace
- Repeated word
- Blank lines
- Markdown link
- Quoted string
- Domain name
- File extension
- Base64
- Trailing comma