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
/
[ ]*(.*)\n[ ]*- ([0-9]{1,5}) bytes:\n(?:[ ]*([0-9A-F]{8}) (?:([0-9A-F]{2}) ){8} (?:([0-9A-F]{2}) ){8} .{16}\n)*[ ]*([0-9A-F]{8}) (?:([0-9A-F]{2}| ) ){8} (?:([0-9A-F]{2}| ) ){8} .{0,16}\n
/
gmi
Match a single character present in the list below
[ ]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
1st Capturing Group
(.*)
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\n matches a line-feed (newline) character (ASCII 10)
Match a single character present in the list below
[ ]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
-
matches the characters - literally (case insensitive)
2nd Capturing Group
([0-9]{1,5})
Match a single character present in the list below
[0-9]
{1,5} matches the previous token between 1 and 5 times, as many times as possible, giving back as needed (greedy)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case insensitive)
bytes:
matches the characters bytes: literally (case insensitive)
\n matches a line-feed (newline) character (ASCII 10)
Non-capturing group
(?:[ ]*([0-9A-F]{8}) (?:([0-9A-F]{2}) ){8} (?:([0-9A-F]{2}) ){8} .{16}\n)*
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Match a single character present in the list below
[ ]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
3rd Capturing Group
([0-9A-F]{8})
Match a single character present in the list below
[0-9A-F]
{8} matches the previous token exactly 8 times
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 65) and F (index 70) (case insensitive)
matches the characters literally (case insensitive)
Non-capturing group
(?:([0-9A-F]{2}) ){8}
{8} matches the previous token exactly 8 times
4th Capturing Group
([0-9A-F]{2})
Match a single character present in the list below
[0-9A-F]
{2} matches the previous token exactly 2 times
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 65) and F (index 70) (case insensitive)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
Non-capturing group
(?:([0-9A-F]{2}) ){8}
{8} matches the previous token exactly 8 times
5th Capturing Group
([0-9A-F]{2})
Match a single character present in the list below
[0-9A-F]
{2} matches the previous token exactly 2 times
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 65) and F (index 70) (case insensitive)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
matches the characters literally (case insensitive)
.
matches any character (except for line terminators)
\n matches a line-feed (newline) character (ASCII 10)
Match a single character present in the list below
[ ]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
6th Capturing Group
([0-9A-F]{8})
Match a single character present in the list below
[0-9A-F]
{8} matches the previous token exactly 8 times
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 65) and F (index 70) (case insensitive)
matches the characters literally (case insensitive)
Non-capturing group
(?:([0-9A-F]{2}| ) ){8}
{8} matches the previous token exactly 8 times
7th Capturing Group
([0-9A-F]{2}| )
1st Alternative
[0-9A-F]{2}
Match a single character present in the list below
[0-9A-F]
{2} matches the previous token exactly 2 times
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 65) and F (index 70) (case insensitive)
2nd Alternative
matches the character with index 3210 (2016 or 408) literally (case insensitive)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
Non-capturing group
(?:([0-9A-F]{2}| ) ){8}
matches the characters literally (case insensitive)
.
matches any character (except for line terminators)
\n matches a line-feed (newline) character (ASCII 10)
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)
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

/
/
gmi

Test String