Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here you go: <code>/^[A-Z]{1}[a-z]{2}\s[0-9]{1,2},\s[0-9]{4},\s[0-9]{1,2}[a|p]m\s[A-Z]{3}\:$/</code></p> <pre><code>'Nov 18, 2013, 4pm CST'.match(/^[A-Z]{1}[a-z]{2}\s[0-9]{1,2},\s[0-9]{4},\s[0-9]{1,2}[a|p]m\s[A-Z]{3}\:$/) ["Nov 18, 2013, 4pm CST"] </code></pre> <p>Keep in mind that this regex is expecting the line to start and end with this date, if the date is contained within other text, remove the <code>^</code> from the start and the <code>$</code> from the end. </p> <p>Hope this helps.</p> <p>To further explain the regex and hopefully ++ your "regex-fu"</p> <ul> <li>[A-Z]{1} - match one upper case letter</li> <li>[a-z]{2} - match two lower case letters</li> </ul> <p>So far we are at Nov, Oct, Jan, etc.</p> <ul> <li>\s - space</li> <li>[0-9]{1,2} - a 1 (min) or 2 (max) digit number</li> <li>, - literal comma</li> <li>\s - space</li> <li>[0-9]{4} - a 4 digit number (the year)</li> </ul> <p>So now we have matched: Nov 18, 2013</p> <ul> <li>, - literal comma</li> <li>\s - space</li> <li>[0-9]{1,2} - just like before, a one or two digit number</li> <li>[a|p]m - 'a' or 'p' followed by an 'm'</li> </ul> <p>Now we've matched: Nov 18, 2013, 4pm</p> <ul> <li>[A-Z]{3} An upper case three character string</li> <li>\: literal colon</li> </ul> <p>That is the entire string. </p> <p>Putting <code>^</code> at the beginning of the regex means the text we are matching against MUST begin with the pattern; similarly, the <code>$</code> states that the text we are matching MUST end with the pattern.</p> <p>Good luck!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload