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 (6)
/
^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/(\d{4}))|((29\/02\/(\d{2})(([02468][048])|([13579][26]))))$
/
g
1st Alternative
^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/(\d{4}))
^ asserts position at start of the string
1st Capturing Group
(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/(\d{4}))
2nd Capturing Group
((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))
1st Alternative
(((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))
3rd Capturing Group
(((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))
4th Capturing Group
((0[1-9])|(1\d)|(2[0-8]))
1st Alternative
(0[1-9])
5th Capturing Group
(0[1-9])
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)
2nd Alternative
(1\d)
6th Capturing Group
(1\d)
1 matches the character 1 with index 4910 (3116 or 618) literally (case sensitive)
\d matches a digit (equivalent to [0-9])
3rd Alternative
(2[0-8])
7th Capturing Group
(2[0-8])
2 matches the character 2 with index 5010 (3216 or 628) literally (case sensitive)
Match a single character present in the list below
[0-8]
0-8 matches a single character in the range between 0 (index 48) and 8 (index 56) (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
8th Capturing Group
((0[1-9])|(1[0-2]))
1st Alternative
(0[1-9])
9th Capturing Group
(0[1-9])
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)
2nd Alternative
(1[0-2])
10th Capturing Group
(1[0-2])
1 matches the character 1 with index 4910 (3116 or 618) literally (case sensitive)
Match a single character present in the list below
[0-2]
0-2 matches a single character in the range between 0 (index 48) and 2 (index 50) (case sensitive)
2nd Alternative
((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2]))))
11th Capturing Group
((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2]))))
1st Alternative
(31\/((0[13578])|(1[02])))
12th Capturing Group
(31\/((0[13578])|(1[02])))
31
matches the characters 31 literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
13th Capturing Group
((0[13578])|(1[02]))
1st Alternative
(0[13578])
14th Capturing Group
(0[13578])
0 matches the character 0 with index 4810 (3016 or 608) literally (case sensitive)
Match a single character present in the list below
[13578]
13578
matches a single character in the list 13578 (case sensitive)
2nd Alternative
(1[02])
15th Capturing Group
(1[02])
1 matches the character 1 with index 4910 (3116 or 618) literally (case sensitive)
Match a single character present in the list below
[02]
02
matches a single character in the list 02 (case sensitive)
2nd Alternative
((29|30)\/((0[1,3-9])|(1[0-2])))
16th Capturing Group
((29|30)\/((0[1,3-9])|(1[0-2])))
17th Capturing Group
(29|30)
1st Alternative
29
29
matches the characters 29 literally (case sensitive)
2nd Alternative
30
30
matches the characters 30 literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
18th Capturing Group
((0[1,3-9])|(1[0-2]))
1st Alternative
(0[1,3-9])
19th Capturing Group
(0[1,3-9])
0 matches the character 0 with index 4810 (3016 or 608) literally (case sensitive)
Match a single character present in the list below
[1,3-9]
1,
matches a single character in the list 1, (case sensitive)
3-9 matches a single character in the range between 3 (index 51) and 9 (index 57) (case sensitive)
2nd Alternative
(1[0-2])
20th Capturing Group
(1[0-2])
1 matches the character 1 with index 4910 (3116 or 618) literally (case sensitive)
Match a single character present in the list below
[0-2]
0-2 matches a single character in the range between 0 (index 48) and 2 (index 50) (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
21st Capturing Group
(\d{4})
\d
matches a digit (equivalent to [0-9])
{4} matches the previous token exactly 4 times
2nd Alternative
((29\/02\/(\d{2})(([02468][048])|([13579][26]))))$
22nd Capturing Group
((29\/02\/(\d{2})(([02468][048])|([13579][26]))))
23rd Capturing Group
(29\/02\/(\d{2})(([02468][048])|([13579][26])))
29
matches the characters 29 literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
02
matches the characters 02 literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
24th Capturing Group
(\d{2})
\d
matches a digit (equivalent to [0-9])
{2} matches the previous token exactly 2 times
25th Capturing Group
(([02468][048])|([13579][26]))
1st Alternative
([02468][048])
26th Capturing Group
([02468][048])
Match a single character present in the list below
[02468]
02468
matches a single character in the list 02468 (case sensitive)
Match a single character present in the list below
[048]
048
matches a single character in the list 048 (case sensitive)
2nd Alternative
([13579][26])
27th Capturing Group
([13579][26])
Match a single character present in the list below
[13579]
13579
matches a single character in the list 13579 (case sensitive)
Match a single character present in the list below
[26]
26
matches a single character in the list 26 (case sensitive)
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
Global pattern flags
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
g

Test String