Regex for Month name
English month name, full or abbreviated.
The Month name regex is ^(January|February|March|April|May|June|July|August|September|October|November|December|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$ — copy it below, or open it in the explainer for a token-by-token breakdown.
The pattern
^(January|February|March|April|May|June|July|August|September|October|November|December|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$
What it matches
JanuaryFebMarchdec? no
What it doesn't match
januaryfebr13
Notes & gotchas
English month names, full or 3-letter abbreviation. Case-sensitive — add /i flag if needed. For other languages, build a similar alternation.
Code in your language
Use the explainer's Code tab to generate ready-to-paste snippets in JavaScript, Python, Java, .NET, Go, Ruby, and PHP for this pattern.
Open in explainer →Token-by-token breakdown
Every part of the pattern, left to right:
| Token | Meaning |
|---|---|
^ | start of string (or line in multiline mode) |
( | start of a capturing group |
January | literal text “January” |
| | OR — try the alternative |
February | literal text “February” |
| | OR — try the alternative |
March | literal text “March” |
| | OR — try the alternative |
April | literal text “April” |
| | OR — try the alternative |
May | literal text “May” |
| | OR — try the alternative |
June | literal text “June” |
| | OR — try the alternative |
July | literal text “July” |
| | OR — try the alternative |
August | literal text “August” |
| | OR — try the alternative |
September | literal text “September” |
| | OR — try the alternative |
October | literal text “October” |
| | OR — try the alternative |
November | literal text “November” |
| | OR — try the alternative |
December | literal text “December” |
| | OR — try the alternative |
Jan | literal text “Jan” |
| | OR — try the alternative |
Feb | literal text “Feb” |
| | OR — try the alternative |
Mar | literal text “Mar” |
| | OR — try the alternative |
Apr | literal text “Apr” |
| | OR — try the alternative |
May | literal text “May” |
| | OR — try the alternative |
Jun | literal text “Jun” |
| | OR — try the alternative |
Jul | literal text “Jul” |
| | OR — try the alternative |
Aug | literal text “Aug” |
| | OR — try the alternative |
Sep | literal text “Sep” |
| | OR — try the alternative |
Oct | literal text “Oct” |
| | OR — try the alternative |
Nov | literal text “Nov” |
| | OR — try the alternative |
Dec | literal text “Dec” |
) | end of group |
$ | end of string (or line in multiline mode) |
About this pattern
Date and time formats vary enormously across regions and systems. The regex here validates structure only — a date like 2024-02-30 would pass format validation but isn't a real date. After regex passes, parse with your language's date library to confirm semantic validity.
Quick usage in different languages
This exact pattern — with the correct escaping and idioms for each language:
- JavaScript:
/^(January|February|March|April|May|June|July|August|September|October|November|December|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$/.test(value) - Python:
re.match(r"^(January|February|March|April|May|June|July|August|September|October|November|December|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$", value) - Java:
Pattern.compile("^(January|February|March|April|May|June|July|August|September|October|November|December|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$").matcher(value).matches() - C# / .NET:
Regex.IsMatch(value, @"^(January|February|March|April|May|June|July|August|September|October|November|December|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$") - Go:
regexp.MustCompile(`^(January|February|March|April|May|June|July|August|September|October|November|December|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$`).MatchString(value) - Ruby:
/^(January|February|March|April|May|June|July|August|September|October|November|December|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$/.match?(value) - PHP:
preg_match('~^(January|February|March|April|May|June|July|August|September|October|November|December|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$~', $value)
The explainer’s Code tab regenerates these for any pattern you paste, and the downloadable cheat sheet bundles the breakdown, all seven snippets, and the pitfalls below onto one printable page.
Common pitfalls
- Anchored to the whole string. This pattern uses ^ and $, so it requires the entire input to match. To find it inside a longer text, drop the anchors and use the global (g) flag.
- Validate beyond format. Matching the format doesn't guarantee the value is real. Confirm the month name against a source of truth (database, API, or checksum) where it matters.
Related patterns
More patterns in the Date & time category:
- ISO 8601 week date
- Day of week name
- RFC 2822 date
- Year + quarter
- Unix timestamp (milliseconds)
- Cron expression (5-field)
See also
Browse all 300 patterns in the library, or open this regex in the interactive explainer to see a token-by-token breakdown, test against custom input, and generate code in seven languages.