Regular Expressions 101

Save & Share

Flavor

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

Function

  • Match
  • Substitution
  • List
  • Unit Tests
"
(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|June?|July?|Aug(ust)?|Sep(t(ember)?)?|Oct(ober)?|Nov(ember)?|Dec(ember)?)[ ](3[01]|[12][0-9]|[0][1-9]|[1-9])[,][ ](20\d{2})
"
1st Capturing Group
(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|June?|July?|Aug(ust)?|Sep(t(ember)?)?|Oct(ober)?|Nov(ember)?|Dec(ember)?)
1st Alternative
Jan(uary)?
Jan
matches the characters Jan literally (case sensitive)
2nd Capturing Group
(uary)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
uary
matches the characters uary literally (case sensitive)
2nd Alternative
Feb(ruary)?
Feb
matches the characters Feb literally (case sensitive)
3rd Capturing Group
(ruary)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
ruary
matches the characters ruary literally (case sensitive)
3rd Alternative
Mar(ch)?
Mar
matches the characters Mar literally (case sensitive)
4th Capturing Group
(ch)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
ch
matches the characters ch literally (case sensitive)
4th Alternative
Apr(il)?
Apr
matches the characters Apr literally (case sensitive)
5th Capturing Group
(il)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
il
matches the characters il literally (case sensitive)
5th Alternative
May
May
matches the characters May literally (case sensitive)
6th Alternative
June?
Jun
matches the characters Jun literally (case sensitive)
e
matches the character e with index 10110 (6516 or 1458) literally (case sensitive)
7th Alternative
July?
Jul
matches the characters Jul literally (case sensitive)
y
matches the character y with index 12110 (7916 or 1718) literally (case sensitive)
8th Alternative
Aug(ust)?
Aug
matches the characters Aug literally (case sensitive)
6th Capturing Group
(ust)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
ust
matches the characters ust literally (case sensitive)
9th Alternative
Sep(t(ember)?)?
Sep
matches the characters Sep literally (case sensitive)
7th Capturing Group
(t(ember)?)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
t matches the character t with index 11610 (7416 or 1648) literally (case sensitive)
8th Capturing Group
(ember)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
ember
matches the characters ember literally (case sensitive)
10th Alternative
Oct(ober)?
Oct
matches the characters Oct literally (case sensitive)
9th Capturing Group
(ober)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
ober
matches the characters ober literally (case sensitive)
11th Alternative
Nov(ember)?
Nov
matches the characters Nov literally (case sensitive)
10th Capturing Group
(ember)?
12th Alternative
Dec(ember)?
Match a single character present in the list below
[ ]
matches the character with index 3210 (2016 or 408) literally (case sensitive)
12th Capturing Group
(3[01]|[12][0-9]|[0][1-9]|[1-9])
1st Alternative
3[01]
3 matches the character 3 with index 5110 (3316 or 638) literally (case sensitive)
Match a single character present in the list below
[01]
01
matches a single character in the list 01 (case sensitive)
2nd Alternative
[12][0-9]
Match a single character present in the list below
[12]
12
matches a single character in the list 12 (case sensitive)
Match a single character present in the list below
[0-9]
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
3rd Alternative
[0][1-9]
Match a single character present in the list below
[0]
0 matches the character 0 with index 4810 (3016 or 608) literally (case sensitive)
Match a single character present in the list below
[1-9]
1-9 matches a single character in the range between 1 (index 49) and 9 (index 57) (case sensitive)
4th Alternative
[1-9]
Match a single character present in the list below
[1-9]
1-9 matches a single character in the range between 1 (index 49) and 9 (index 57) (case sensitive)
Match a single character present in the list below
[,]
, matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
Match a single character present in the list below
[ ]
matches the character with index 3210 (2016 or 408) literally (case sensitive)
13th Capturing Group
(20\d{2})
20
matches the characters 20 literally (case sensitive)
\d
matches a digit (equivalent to [0-9])
{2} matches the previous token exactly 2 times
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"

Test String