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
"
^30([0-4][0-9a-f])(02([0-2][0-9a-f])(00)?[a-f0-9]{2,64})(02([0-2][0-9a-f])(00)?[a-f0-9]{2,64})(01|02|03|81|82|83)?$
"
i
^ asserts position at start of the string
30
matches the characters 30 literally (case insensitive)
1st Capturing Group
([0-4][0-9a-f])
Match a single character present in the list below
[0-4]
0-4 matches a single character in the range between 0 (index 48) and 4 (index 52) (case insensitive)
Match a single character present in the list below
[0-9a-f]
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case insensitive)
a-f matches a single character in the range between a (index 97) and f (index 102) (case insensitive)
2nd Capturing Group
(02([0-2][0-9a-f])(00)?[a-f0-9]{2,64})
02
matches the characters 02 literally (case insensitive)
3rd Capturing Group
([0-2][0-9a-f])
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 insensitive)
Match a single character present in the list below
[0-9a-f]
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case insensitive)
a-f matches a single character in the range between a (index 97) and f (index 102) (case insensitive)
4th Capturing Group
(00)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
00
matches the characters 00 literally (case insensitive)
Match a single character present in the list below
[a-f0-9]
{2,64} matches the previous token between 2 and 64 times, as many times as possible, giving back as needed (greedy)
a-f matches a single character in the range between a (index 97) and f (index 102) (case insensitive)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case insensitive)
5th Capturing Group
(02([0-2][0-9a-f])(00)?[a-f0-9]{2,64})
02
matches the characters 02 literally (case insensitive)
6th Capturing Group
([0-2][0-9a-f])
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 insensitive)
Match a single character present in the list below
[0-9a-f]
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case insensitive)
a-f matches a single character in the range between a (index 97) and f (index 102) (case insensitive)
7th Capturing Group
(00)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
00
matches the characters 00 literally (case insensitive)
Match a single character present in the list below
[a-f0-9]
{2,64} matches the previous token between 2 and 64 times, as many times as possible, giving back as needed (greedy)
a-f matches a single character in the range between a (index 97) and f (index 102) (case insensitive)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case insensitive)
8th Capturing Group
(01|02|03|81|82|83)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
1st Alternative
01
01
matches the characters 01 literally (case insensitive)
2nd Alternative
02
02
matches the characters 02 literally (case insensitive)
3rd Alternative
03
03
matches the characters 03 literally (case insensitive)
4th Alternative
81
81
matches the characters 81 literally (case insensitive)
5th Alternative
82
82
matches the characters 82 literally (case insensitive)
6th Alternative
83
83
matches the characters 83 literally (case insensitive)
$ 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
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"
i

Test String