Regular Expressions 101

@regex101
Donate
Sponsor
Contact
Bug Reports & Feedback
Wiki
Whats new?

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python 2.7
  • Golang
  • Java 8

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
^.((?:\b\d\D)?\b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June|July|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|(?:Nov|Dec)(?:ember)?)\D(?:\d\D)?\D(?:(?:19[7-9]\d|20\d)|\d))
/
gm
^ asserts position at start of a line
.
matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
1st Capturing Group
((?:\b\d\D)?\b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June|July|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|(?:Nov|Dec)(?:ember)?)\D(?:\d\D)?\D(?:(?:19[7-9]\d|20\d)|\d))
Non-capturing group
(?:\b\d\D)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
\d
matches a digit (equivalent to [0-9])
{1,2} matches the previous token between 1 and 2 times, as many times as possible, giving back as needed (greedy)
\D
matches any character that's not a digit (equivalent to [^0-9])
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
Non-capturing group
(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June|July|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|(?:Nov|Dec)(?:ember)?)
1st Alternative
Jan(?:uary)?
Jan matches the characters Jan literally (case sensitive)
Non-capturing group
(?:uary)?
2nd Alternative
Feb(?:ruary)?
Feb matches the characters Feb literally (case sensitive)
Non-capturing group
(?:ruary)?
3rd Alternative
Mar(?:ch)?
4th Alternative
Apr(?:il)?
5th Alternative
May
6th Alternative
June
7th Alternative
July
8th Alternative
Aug(?:ust)?
9th Alternative
Sep(?:tember)?
10th Alternative
Oct(?:ober)?
11th Alternative
(?:Nov|Dec)(?:ember)?
\D
matches any character that's not a digit (equivalent to [^0-9])
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
Non-capturing group
(?:\d\D)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\d
matches a digit (equivalent to [0-9])
\D
matches any character that's not a digit (equivalent to [^0-9])
\D
matches any character that's not a digit (equivalent to [^0-9])
Non-capturing group
(?:(?:19[7-9]\d|20\d)|\d)
Global pattern flags
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gm

Test String