Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4592086
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:29:17+00:00 2026-05-21T22:29:17+00:00

Anybody can help compose regular expression for this logic? MM/DD/YYYY hh:mm AM/PM MM/DD/YYYY hh

  • 0

Anybody can help compose regular expression for this logic?

MM/DD/YYYY hh:mm AM/PM 
MM/DD/YYYY hh AM/PM 
MM/DD/YYYY 
MM/YYYY 
YYYY 

[Date templates]

M/D/YY 
M/YY 
M/YYYY 
M/D/YYYY 

MMM YY 
MMM YYYY 
MMMM YY 
MMMM YYYY 

YY/M 
YY-M 
YY.M 

YYYY/M 
YYYY-M 
YYYY.M 

YYYY 

YYYY/M/D 
YYYY-M-D 
YYYY.M.D 

M-D-YY 
M-YY 
M-YYYY 
M-D-YYYY 

M.D.YY 
M.YY 
M.YYYY 
M.D.YYYY 

MMM D[,] YY 
MMM D[,] YYYY 

MMMM D[,] YY 
MMMM D[,] YYYY 

D MMM[,] YY 
D MMM[,] YYYY 

D MMMM[,] YY 
D MMMM[,] YYYY 

[Time templates]

hh:mm AM (or PM or A or P) 
hh AM (or PM or A or P) 
HH:mm 

YY two-digit year (00 => 2000, 10 => 2010) 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T22:29:18+00:00Added an answer on May 21, 2026 at 10:29 pm

    To give you some hints:
    You have different ways to specify a month: M, MM, MMMM

    M means its a number, so you can write it like [0-9] (there are even more compact ways, but I think this requires the least explanation).

    MM means you can have another digit, but this digit can obviously only be 1, as 12 is the highest.

    So we alter the expression: 1?[0-9]. Which means the one is optional.

    Is this correct? No, because it would e.g. accept 0 as a valid month. So alter it again.

    (1[0-2]|[1-9]) which means: either a 1 followed by another digit between 0 and 2, so 10, 11, 12 are accepted. The braces are there to create a group.

    Now to accept MMMM

    (1[0-2]|[1-9]|January|February) etc.

    This can be further composed, e.g. for MM/YYYY and YYYY

    ((1[0-2]|[1-9]|January|February)/)?<YYYY-Pattern>

    Also don’t forget to match the start and the beginning:

    ^((1[0-2]|[1-9]|January|February)/)?<YYYY-Pattern>$

    otherwise you’d match things like abc MM/DD/YYYY bla

    If everything works, you should use non-capturing groups where you don’t need to reference the contents of a group. So ^((1[0-2]|[1-9]|January|February)/)?<YYYY-Pattern>$ becomes ^(?:(1[0-2]|[1-9]|January|February)/)?<YYYY-Pattern>$ because you probably don’t need to reference the group with the /. (However I think this is implementation dependent). To reference the groupse you probably want to give them names. Have a look here: http://www.regular-expressions.info/named.html

    Well that’s the way I compose regular expressions…

    Don’t give up, its going to be a longer expression, but not a very complex one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody help me writing a regular expression to replace these characters with a
can anybody help me understand how Honda achieved this effect: http://testdays.hondamoto.ch/ I mean the
Can anybody help me with this simple code?? #include <iostream> using namespace std; void
can anybody help me solve this : i got $filename= index 198.php; i use
Anybody can help me to get date formated with Zend framework What I do
I need to retrieve data from within a specific date range.Anybody can help me
Wish anybody can help me with this error Column 'Sales.No_' is invalid in the
i have this .js file for the pagination in html anybody can help me
Anybody can help me with this code I am getting this error message: Server
I can't remove this loops by myself, if anybody can help me with optimization

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.