Reputation: 367
How do I throw this into a regular expression where MON can be any three letter month and YYYY is the year, etc..?
MON ## - MON ##, YYYY
MON ##, YYY1 - MON ##, YYY2
MO1 ## - MO2 ##, YYYY
MON ## - MON ##, YYYY
Upvotes: 0
Views: 532
Reputation: 183612
I suppose that would be
Pattern.compile
(
"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \\d\\d(, \\d\\d\\d\\d)?" +
" - (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \\d\\d, \\d\\d\\d\\d"
)
(Note: you may need to tweak that to account for things that aren't clear in your question — for example, can the day-of-month be just one digit, or must it be two?)
But I have to wonder if this is the best way to do whatever it is that you're trying to do. Are you familiar with java.text.SimpleDateFormat
? (What exactly is it that you're trying to do?)
Upvotes: 2