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
/
(^(((\d\d)(([02468][048])|([13579][26]))-02-29)|(((\d\d)(\d\d)))-((((0\d)|(1[0-2]))-((0\d)|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))\s(([01]\d|2[0-3]):([0-5]\d):([0-5]\d))$)
/
1st Capturing Group
(^(((\d\d)(([02468][048])|([13579][26]))-02-29)|(((\d\d)(\d\d)))-((((0\d)|(1[0-2]))-((0\d)|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))\s(([01]\d|2[0-3]):([0-5]\d):([0-5]\d))$)
^ asserts position at start of the string
2nd Capturing Group
(((\d\d)(([02468][048])|([13579][26]))-02-29)|(((\d\d)(\d\d)))-((((0\d)|(1[0-2]))-((0\d)|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))
1st Alternative
((\d\d)(([02468][048])|([13579][26]))-02-29)
3rd Capturing Group
((\d\d)(([02468][048])|([13579][26]))-02-29)
4th Capturing Group
(\d\d)
\d matches a digit (equivalent to [0-9])
\d matches a digit (equivalent to [0-9])
5th Capturing Group
(([02468][048])|([13579][26]))
1st Alternative
([02468][048])
6th 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])
7th 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)
-02-29
matches the characters -02-29 literally (case sensitive)
2nd Alternative
(((\d\d)(\d\d)))-((((0\d)|(1[0-2]))-((0\d)|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30))))
8th Capturing Group
(((\d\d)(\d\d)))
9th Capturing Group
((\d\d)(\d\d))
10th Capturing Group
(\d\d)
\d matches a digit (equivalent to [0-9])
\d matches a digit (equivalent to [0-9])
11th Capturing Group
(\d\d)
\d matches a digit (equivalent to [0-9])
\d matches a digit (equivalent to [0-9])
- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
12th Capturing Group
((((0\d)|(1[0-2]))-((0\d)|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30))))
1st Alternative
(((0\d)|(1[0-2]))-((0\d)|(1\d)|(2[0-8])))
13th Capturing Group
(((0\d)|(1[0-2]))-((0\d)|(1\d)|(2[0-8])))
14th Capturing Group
((0\d)|(1[0-2]))
1st Alternative
(0\d)
15th Capturing Group
(0\d)
0 matches the character 0 with index 4810 (3016 or 608) literally (case sensitive)
\d matches a digit (equivalent to [0-9])
2nd Alternative
(1[0-2])
16th 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 4510 (2D16 or 558) literally (case sensitive)
17th Capturing Group
((0\d)|(1\d)|(2[0-8]))
1st Alternative
(0\d)
18th Capturing Group
(0\d)
0 matches the character 0 with index 4810 (3016 or 608) literally (case sensitive)
\d matches a digit (equivalent to [0-9])
2nd Alternative
(1\d)
19th 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])
20th 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)
2nd Alternative
((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))
21st Capturing Group
((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))
1st Alternative
(((0[13578])|(1[02]))-31)
22nd Capturing Group
(((0[13578])|(1[02]))-31)
23rd Capturing Group
((0[13578])|(1[02]))
1st Alternative
(0[13578])
24th 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])
25th 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)
-31
matches the characters -31 literally (case sensitive)
2nd Alternative
(((0[1,3-9])|(1[0-2]))-(29|30))
26th Capturing Group
(((0[1,3-9])|(1[0-2]))-(29|30))
27th Capturing Group
((0[1,3-9])|(1[0-2]))
1st Alternative
(0[1,3-9])
28th 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])
29th 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 4510 (2D16 or 558) literally (case sensitive)
30th 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)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
31st Capturing Group
(([01]\d|2[0-3]):([0-5]\d):([0-5]\d))
32nd Capturing Group
([01]\d|2[0-3])
1st Alternative
[01]\d
Match a single character present in the list below
[01]
01
matches a single character in the list 01 (case sensitive)
\d matches a digit (equivalent to [0-9])
2nd Alternative
2[0-3]
2 matches the character 2 with index 5010 (3216 or 628) literally (case sensitive)
Match a single character present in the list below
[0-3]
0-3 matches a single character in the range between 0 (index 48) and 3 (index 51) (case sensitive)
: matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
33rd Capturing Group
([0-5]\d)
Match a single character present in the list below
[0-5]
0-5 matches a single character in the range between 0 (index 48) and 5 (index 53) (case sensitive)
\d matches a digit (equivalent to [0-9])
: matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
34th Capturing Group
([0-5]\d)
Match a single character present in the list below
[0-5]
0-5 matches a single character in the range between 0 (index 48) and 5 (index 53) (case sensitive)
\d matches a digit (equivalent to [0-9])
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/

Test String