Regular Expressions 101

Save & Share

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

Flavor

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

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
^(?!$|0.)([07]*(?:[18](?2)|[29](?3)|3(?4)|4(?5)|5(?7)|6(?9)|$))|(5*(?:[07](?4)|[18](?5)|[29](?7)|4(?1)|6(?3)|3(?9)))(3*(?:[18](?1)|[29](?2)|[07](?9)|4(?4)|5(?5)|6(?7)))([18]*(?:[07](?3)|[29](?5)|5(?1)|6(?2)|3(?7)|4(?9)))(6*([29](?1)|[07](?7)|[18](?9)|3(?2)|4(?3)|5(?4)))(4*([07](?2)|[18](?3)|[29](?4)|6(?1)|3(?5)|5(?9)))([29]*([07](?5)|[18](?7)|3(?1)|4(?2)|5(?3)|6(?4)))
/
1st Alternative
^(?!$|0.)([07]*(?:[18](?2)|[29](?3)|3(?4)|4(?5)|5(?7)|6(?9)|$))
^ asserts position at start of the string
Negative Lookahead
(?!$|0.)
Assert that the Regex below does not match
1st Alternative
$
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
2nd Alternative
0.
0 matches the character 0 with index 4810 (3016 or 608) literally (case sensitive)
. matches any character (except for line terminators)
1st Capturing Group
([07]*(?:[18](?2)|[29](?3)|3(?4)|4(?5)|5(?7)|6(?9)|$))
Match a single character present in the list below
[07]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
07
matches a single character in the list 07 (case sensitive)
Non-capturing group
(?:[18](?2)|[29](?3)|3(?4)|4(?5)|5(?7)|6(?9)|$)
1st Alternative
[18](?2)
Match a single character present in the list below
[18]
18
matches a single character in the list 18 (case sensitive)
(?2) recurses the 2nd subpattern
2nd Alternative
[29](?3)
Match a single character present in the list below
[29]
29
matches a single character in the list 29 (case sensitive)
(?3) recurses the 3rd subpattern
3rd Alternative
3(?4)
3 matches the character 3 with index 5110 (3316 or 638) literally (case sensitive)
(?4) recurses the 4th subpattern
4th Alternative
4(?5)
4 matches the character 4 with index 5210 (3416 or 648) literally (case sensitive)
(?5) recurses the 5th subpattern
5th Alternative
5(?7)
5 matches the character 5 with index 5310 (3516 or 658) literally (case sensitive)
(?7) recurses the 7th subpattern
6th Alternative
6(?9)
6 matches the character 6 with index 5410 (3616 or 668) literally (case sensitive)
(?9) recurses the 9th subpattern
7th Alternative
$
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
2nd Alternative
(5*(?:[07](?4)|[18](?5)|[29](?7)|4(?1)|6(?3)|3(?9)))(3*(?:[18](?1)|[29](?2)|[07](?9)|4(?4)|5(?5)|6(?7)))([18]*(?:[07](?3)|[29](?5)|5(?1)|6(?2)|3(?7)|4(?9)))(6*([29](?1)|[07](?7)|[18](?9)|3(?2)|4(?3)|5(?4)))(4*([07](?2)|[18](?3)|[29](?4)|6(?1)|3(?5)|5(?9)))([29]*([07](?5)|[18](?7)|3(?1)|4(?2)|5(?3)|6(?4)))
2nd Capturing Group
(5*(?:[07](?4)|[18](?5)|[29](?7)|4(?1)|6(?3)|3(?9)))
5
matches the character 5 with index 5310 (3516 or 658) literally (case sensitive)
Non-capturing group
(?:[07](?4)|[18](?5)|[29](?7)|4(?1)|6(?3)|3(?9))
1st Alternative
[07](?4)
Match a single character present in the list below
[07]
07
matches a single character in the list 07 (case sensitive)
(?4) recurses the 4th subpattern
2nd Alternative
[18](?5)
Match a single character present in the list below
[18]
18
matches a single character in the list 18 (case sensitive)
(?5) recurses the 5th subpattern
3rd Alternative
[29](?7)
Match a single character present in the list below
[29]
29
matches a single character in the list 29 (case sensitive)
(?7) recurses the 7th subpattern
4th Alternative
4(?1)
4 matches the character 4 with index 5210 (3416 or 648) literally (case sensitive)
(?1) recurses the 1st subpattern
5th Alternative
6(?3)
6 matches the character 6 with index 5410 (3616 or 668) literally (case sensitive)
(?3) recurses the 3rd subpattern
6th Alternative
3(?9)
3 matches the character 3 with index 5110 (3316 or 638) literally (case sensitive)
(?9) recurses the 9th subpattern
3rd Capturing Group
(3*(?:[18](?1)|[29](?2)|[07](?9)|4(?4)|5(?5)|6(?7)))
3
matches the character 3 with index 5110 (3316 or 638) literally (case sensitive)
Non-capturing group
(?:[18](?1)|[29](?2)|[07](?9)|4(?4)|5(?5)|6(?7))
1st Alternative
[18](?1)
Match a single character present in the list below
[18]
18
matches a single character in the list 18 (case sensitive)
(?1) recurses the 1st subpattern
2nd Alternative
[29](?2)
Match a single character present in the list below
[29]
29
matches a single character in the list 29 (case sensitive)
(?2) recurses the 2nd subpattern
3rd Alternative
[07](?9)
Match a single character present in the list below
[07]
07
matches a single character in the list 07 (case sensitive)
(?9) recurses the 9th subpattern
4th Alternative
4(?4)
4 matches the character 4 with index 5210 (3416 or 648) literally (case sensitive)
(?4) recurses the 4th subpattern
5th Alternative
5(?5)
5 matches the character 5 with index 5310 (3516 or 658) literally (case sensitive)
(?5) recurses the 5th subpattern
6th Alternative
6(?7)
6 matches the character 6 with index 5410 (3616 or 668) literally (case sensitive)
(?7) recurses the 7th subpattern
4th Capturing Group
([18]*(?:[07](?3)|[29](?5)|5(?1)|6(?2)|3(?7)|4(?9)))
Match a single character present in the list below
[18]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
18
matches a single character in the list 18 (case sensitive)
Non-capturing group
(?:[07](?3)|[29](?5)|5(?1)|6(?2)|3(?7)|4(?9))
1st Alternative
[07](?3)
Match a single character present in the list below
[07]
07
matches a single character in the list 07 (case sensitive)
(?3) recurses the 3rd subpattern
2nd Alternative
[29](?5)
Match a single character present in the list below
[29]
29
matches a single character in the list 29 (case sensitive)
(?5) recurses the 5th subpattern
3rd Alternative
5(?1)
5 matches the character 5 with index 5310 (3516 or 658) literally (case sensitive)
(?1) recurses the 1st subpattern
4th Alternative
6(?2)
6 matches the character 6 with index 5410 (3616 or 668) literally (case sensitive)
(?2) recurses the 2nd subpattern
5th Alternative
3(?7)
3 matches the character 3 with index 5110 (3316 or 638) literally (case sensitive)
(?7) recurses the 7th subpattern
6th Alternative
4(?9)
4 matches the character 4 with index 5210 (3416 or 648) literally (case sensitive)
(?9) recurses the 9th subpattern
5th Capturing Group
(6*([29](?1)|[07](?7)|[18](?9)|3(?2)|4(?3)|5(?4)))
6
matches the character 6 with index 5410 (3616 or 668) literally (case sensitive)
6th Capturing Group
([29](?1)|[07](?7)|[18](?9)|3(?2)|4(?3)|5(?4))
1st Alternative
[29](?1)
Match a single character present in the list below
[29]
29
matches a single character in the list 29 (case sensitive)
(?1) recurses the 1st subpattern
2nd Alternative
[07](?7)
Match a single character present in the list below
[07]
07
matches a single character in the list 07 (case sensitive)
(?7) recurses the 7th subpattern
3rd Alternative
[18](?9)
Match a single character present in the list below
[18]
18
matches a single character in the list 18 (case sensitive)
(?9) recurses the 9th subpattern
4th Alternative
3(?2)
3 matches the character 3 with index 5110 (3316 or 638) literally (case sensitive)
(?2) recurses the 2nd subpattern
5th Alternative
4(?3)
4 matches the character 4 with index 5210 (3416 or 648) literally (case sensitive)
(?3) recurses the 3rd subpattern
6th Alternative
5(?4)
5 matches the character 5 with index 5310 (3516 or 658) literally (case sensitive)
(?4) recurses the 4th subpattern
7th Capturing Group
(4*([07](?2)|[18](?3)|[29](?4)|6(?1)|3(?5)|5(?9)))
4
matches the character 4 with index 5210 (3416 or 648) literally (case sensitive)
8th Capturing Group
([07](?2)|[18](?3)|[29](?4)|6(?1)|3(?5)|5(?9))
1st Alternative
[07](?2)
Match a single character present in the list below
[07]
07
matches a single character in the list 07 (case sensitive)
(?2) recurses the 2nd subpattern
2nd Alternative
[18](?3)
Match a single character present in the list below
[18]
18
matches a single character in the list 18 (case sensitive)
(?3) recurses the 3rd subpattern
3rd Alternative
[29](?4)
Match a single character present in the list below
[29]
29
matches a single character in the list 29 (case sensitive)
(?4) recurses the 4th subpattern
4th Alternative
6(?1)
6 matches the character 6 with index 5410 (3616 or 668) literally (case sensitive)
(?1) recurses the 1st subpattern
5th Alternative
3(?5)
3 matches the character 3 with index 5110 (3316 or 638) literally (case sensitive)
(?5) recurses the 5th subpattern
6th Alternative
5(?9)
9th Capturing Group
([29]*([07](?5)|[18](?7)|3(?1)|4(?2)|5(?3)|6(?4)))
Match a single character present in the list below
[29]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
29
matches a single character in the list 29 (case sensitive)
10th Capturing Group
([07](?5)|[18](?7)|3(?1)|4(?2)|5(?3)|6(?4))
1st Alternative
[07](?5)
Match a single character present in the list below
[07]
07
matches a single character in the list 07 (case sensitive)
(?5) recurses the 5th subpattern
2nd Alternative
[18](?7)
Match a single character present in the list below
[18]
18
matches a single character in the list 18 (case sensitive)
(?7) recurses the 7th subpattern
3rd Alternative
3(?1)
3 matches the character 3 with index 5110 (3316 or 638) literally (case sensitive)
(?1) recurses the 1st subpattern
4th Alternative
4(?2)
4 matches the character 4 with index 5210 (3416 or 648) literally (case sensitive)
(?2) recurses the 2nd subpattern
5th Alternative
5(?3)
6th Alternative
6(?4)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/

Test String

Code Generator

Generated Code

Loading code sample...
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report.
For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php