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
/
^([+-]\d((([02468][048]|[13579][26]|\d\d(?!00))([02468][048]|[13579][26]))|\d(?!-02-29|-366))-((?!02-3|(0[469]|11)-31|000)((0[1-9]|1[012])-(0[1-9]|[12]\d|30|31)|([012]\d\d|3([0-5]\d|6[0-6])))|(W(?!00)([0-4]\d|51|52)-[1-7]))|((\+\d([02468][048]|[13579][26])|-\d([02468][159]|[13579][37]))(04|09|15|20|26|32|37|43|48|54|60|65|71|76|82|88|93|99)|(\+\d([02468][159]|[13579][37])|-\d([02468][26]|[13579][048]))(05|11|16|22|28|33|39|44|50|56|61|67|72|78|84|89|95)|(\+\d([02468][26]|[13579][048])|-\d([02468][37]|[13579][159]))(01|07|12|18|24|29|35|40|46|52|57|63|68|74|80|85|91|96)|\+\d(([02468][37]|[13579][159])(03|14|20|25|31|36|42|53|59|64|70|76|81|87|92|[049]8))|-\d(([02468][048]|[13579][26])([059]2|08|13|19|24|30|36|41|47|58|64|69|75|80|86|97)))-W53-[1-7])$
/
gm
^ asserts position at start of a line
1st Capturing Group
([+-]\d((([02468][048]|[13579][26]|\d\d(?!00))([02468][048]|[13579][26]))|\d(?!-02-29|-366))-((?!02-3|(0[469]|11)-31|000)((0[1-9]|1[012])-(0[1-9]|[12]\d|30|31)|([012]\d\d|3([0-5]\d|6[0-6])))|(W(?!00)([0-4]\d|51|52)-[1-7]))|((\+\d([02468][048]|[13579][26])|-\d([02468][159]|[13579][37]))(04|09|15|20|26|32|37|43|48|54|60|65|71|76|82|88|93|99)|(\+\d([02468][159]|[13579][37])|-\d([02468][26]|[13579][048]))(05|11|16|22|28|33|39|44|50|56|61|67|72|78|84|89|95)|(\+\d([02468][26]|[13579][048])|-\d([02468][37]|[13579][159]))(01|07|12|18|24|29|35|40|46|52|57|63|68|74|80|85|91|96)|\+\d(([02468][37]|[13579][159])(03|14|20|25|31|36|42|53|59|64|70|76|81|87|92|[049]8))|-\d(([02468][048]|[13579][26])([059]2|08|13|19|24|30|36|41|47|58|64|69|75|80|86|97)))-W53-[1-7])
1st Alternative
[+-]\d((([02468][048]|[13579][26]|\d\d(?!00))([02468][048]|[13579][26]))|\d(?!-02-29|-366))-((?!02-3|(0[469]|11)-31|000)((0[1-9]|1[012])-(0[1-9]|[12]\d|30|31)|([012]\d\d|3([0-5]\d|6[0-6])))|(W(?!00)([0-4]\d|51|52)-[1-7]))
Match a single character present in the list below
[+-]
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
+- matches a single character in the list +- (case sensitive)
\d
matches a digit (equivalent to [0-9])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
2nd Capturing Group
((([02468][048]|[13579][26]|\d\d(?!00))([02468][048]|[13579][26]))|\d(?!-02-29|-366))
1st Alternative
(([02468][048]|[13579][26]|\d\d(?!00))([02468][048]|[13579][26]))
3rd Capturing Group
(([02468][048]|[13579][26]|\d\d(?!00))([02468][048]|[13579][26]))
4th Capturing Group
([02468][048]|[13579][26]|\d\d(?!00))
5th Capturing Group
([02468][048]|[13579][26])
2nd Alternative
\d(?!-02-29|-366)
\d
matches a digit (equivalent to [0-9])
{4} matches the previous token exactly 4 times
Negative Lookahead
(?!-02-29|-366)
Assert that the Regex below does not match
- matches the character - literally (case sensitive)
6th Capturing Group
((?!02-3|(0[469]|11)-31|000)((0[1-9]|1[012])-(0[1-9]|[12]\d|30|31)|([012]\d\d|3([0-5]\d|6[0-6])))|(W(?!00)([0-4]\d|51|52)-[1-7]))
1st Alternative
(?!02-3|(0[469]|11)-31|000)((0[1-9]|1[012])-(0[1-9]|[12]\d|30|31)|([012]\d\d|3([0-5]\d|6[0-6])))
Negative Lookahead
(?!02-3|(0[469]|11)-31|000)
Assert that the Regex below does not match
8th Capturing Group
((0[1-9]|1[012])-(0[1-9]|[12]\d|30|31)|([012]\d\d|3([0-5]\d|6[0-6])))
2nd Alternative
(W(?!00)([0-4]\d|51|52)-[1-7])
2nd Alternative
((\+\d([02468][048]|[13579][26])|-\d([02468][159]|[13579][37]))(04|09|15|20|26|32|37|43|48|54|60|65|71|76|82|88|93|99)|(\+\d([02468][159]|[13579][37])|-\d([02468][26]|[13579][048]))(05|11|16|22|28|33|39|44|50|56|61|67|72|78|84|89|95)|(\+\d([02468][26]|[13579][048])|-\d([02468][37]|[13579][159]))(01|07|12|18|24|29|35|40|46|52|57|63|68|74|80|85|91|96)|\+\d(([02468][37]|[13579][159])(03|14|20|25|31|36|42|53|59|64|70|76|81|87|92|[049]8))|-\d(([02468][048]|[13579][26])([059]2|08|13|19|24|30|36|41|47|58|64|69|75|80|86|97)))-W53-[1-7]
15th Capturing Group
((\+\d([02468][048]|[13579][26])|-\d([02468][159]|[13579][37]))(04|09|15|20|26|32|37|43|48|54|60|65|71|76|82|88|93|99)|(\+\d([02468][159]|[13579][37])|-\d([02468][26]|[13579][048]))(05|11|16|22|28|33|39|44|50|56|61|67|72|78|84|89|95)|(\+\d([02468][26]|[13579][048])|-\d([02468][37]|[13579][159]))(01|07|12|18|24|29|35|40|46|52|57|63|68|74|80|85|91|96)|\+\d(([02468][37]|[13579][159])(03|14|20|25|31|36|42|53|59|64|70|76|81|87|92|[049]8))|-\d(([02468][048]|[13579][26])([059]2|08|13|19|24|30|36|41|47|58|64|69|75|80|86|97)))
1st Alternative
(\+\d([02468][048]|[13579][26])|-\d([02468][159]|[13579][37]))(04|09|15|20|26|32|37|43|48|54|60|65|71|76|82|88|93|99)
16th Capturing Group
(\+\d([02468][048]|[13579][26])|-\d([02468][159]|[13579][37]))
1st Alternative
\+\d([02468][048]|[13579][26])
\+
matches the character + literally (case sensitive)
? 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])
17th Capturing Group
([02468][048]|[13579][26])
2nd Alternative
-\d([02468][159]|[13579][37])
- matches the character - literally (case sensitive)
\d
matches a digit (equivalent to [0-9])
18th Capturing Group
([02468][159]|[13579][37])
19th Capturing Group
(04|09|15|20|26|32|37|43|48|54|60|65|71|76|82|88|93|99)
1st Alternative
04
04 matches the characters 04 literally (case sensitive)
2nd Alternative
09
3rd Alternative
15
4th Alternative
20
5th Alternative
26
6th Alternative
32
7th Alternative
37
8th Alternative
43
9th Alternative
48
10th Alternative
54
11th Alternative
60
12th Alternative
65
13th Alternative
71
14th Alternative
76
15th Alternative
82
16th Alternative
88
17th Alternative
93
18th Alternative
99
2nd Alternative
(\+\d([02468][159]|[13579][37])|-\d([02468][26]|[13579][048]))(05|11|16|22|28|33|39|44|50|56|61|67|72|78|84|89|95)
20th Capturing Group
(\+\d([02468][159]|[13579][37])|-\d([02468][26]|[13579][048]))
1st Alternative
\+\d([02468][159]|[13579][37])
\+
matches the character + literally (case sensitive)
\d
matches a digit (equivalent to [0-9])
21st Capturing Group
([02468][159]|[13579][37])
2nd Alternative
-\d([02468][26]|[13579][048])
23rd Capturing Group
(05|11|16|22|28|33|39|44|50|56|61|67|72|78|84|89|95)
1st Alternative
05
2nd Alternative
11
3rd Alternative
16
4th Alternative
22
5th Alternative
28
6th Alternative
33
7th Alternative
39
8th Alternative
44
9th Alternative
50
10th Alternative
56
11th Alternative
61
12th Alternative
67
13th Alternative
72
14th Alternative
78
15th Alternative
84
16th Alternative
89
17th Alternative
95
3rd Alternative
(\+\d([02468][26]|[13579][048])|-\d([02468][37]|[13579][159]))(01|07|12|18|24|29|35|40|46|52|57|63|68|74|80|85|91|96)
24th Capturing Group
(\+\d([02468][26]|[13579][048])|-\d([02468][37]|[13579][159]))
1st Alternative
\+\d([02468][26]|[13579][048])
2nd Alternative
-\d([02468][37]|[13579][159])
27th Capturing Group
(01|07|12|18|24|29|35|40|46|52|57|63|68|74|80|85|91|96)
4th Alternative
\+\d(([02468][37]|[13579][159])(03|14|20|25|31|36|42|53|59|64|70|76|81|87|92|[049]8))
\+
matches the character + literally (case sensitive)
\d
matches a digit (equivalent to [0-9])
28th Capturing Group
(([02468][37]|[13579][159])(03|14|20|25|31|36|42|53|59|64|70|76|81|87|92|[049]8))
5th Alternative
-\d(([02468][048]|[13579][26])([059]2|08|13|19|24|30|36|41|47|58|64|69|75|80|86|97))
-W53- matches the characters -W53- literally (case sensitive)
Match a single character present in the list below
[1-7]
1-7 matches a single character in the range between 1 (index 49) and 7 (index 55) (case sensitive)
$ asserts position at the end of a line
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