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
/
([#.@]?[\w.:> ]+)[\s]{[\r\n]?([A-Za-z\- \r\n\t]+[:][\s]*[\w .\/()\-!]+;[\r\n]*(?:[A-Za-z\- \r\n\t]+[:][\s]*[\w .\/()\-!]+;[\r\n]*(?2)*)*)}
/
g
1st Capturing Group
([#.@]?[\w.:> ]+)
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)
Match a single character present in the list below
[\w.:> ]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\w matches any word character (equivalent to [a-zA-Z0-9_])
.:>
matches a single character in the list .:> (case sensitive)
Match a single character present in the list below
[\s]
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
{ matches the character { with index 12310 (7B16 or 1738) literally (case sensitive)
Match a single character present in the list below
[\r\n]
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\r matches a carriage return (ASCII 13)
\n matches a line-feed (newline) character (ASCII 10)
2nd Capturing Group
([A-Za-z\- \r\n\t]+[:][\s]*[\w .\/()\-!]+;[\r\n]*(?:[A-Za-z\- \r\n\t]+[:][\s]*[\w .\/()\-!]+;[\r\n]*(?2)*)*)
Match a single character present in the list below
[A-Za-z\- \r\n\t]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
\- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
\r matches a carriage return (ASCII 13)
\n matches a line-feed (newline) character (ASCII 10)
\t matches a tab character (ASCII 9)
Match a single character present in the list below
[:]
: matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
Match a single character present in the list below
[\s]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
Match a single character present in the list below
[\w .\/()\-!]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\w matches any word character (equivalent to [a-zA-Z0-9_])
.
matches a single character in the list . (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
()
matches a single character in the list () (case sensitive)
\- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
! matches the character ! with index 3310 (2116 or 418) literally (case sensitive)
; matches the character ; with index 5910 (3B16 or 738) literally (case sensitive)
Match a single character present in the list below
[\r\n]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\r matches a carriage return (ASCII 13)
\n matches a line-feed (newline) character (ASCII 10)
Non-capturing group
(?:[A-Za-z\- \r\n\t]+[:][\s]*[\w .\/()\-!]+;[\r\n]*(?2)*)*
* 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
[A-Za-z\- \r\n\t]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
\- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
\r matches a carriage return (ASCII 13)
\n matches a line-feed (newline) character (ASCII 10)
\t matches a tab character (ASCII 9)
Match a single character present in the list below
[:]
: matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
Match a single character present in the list below
[\s]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
Match a single character present in the list below
[\w .\/()\-!]
; matches the character ; with index 5910 (3B16 or 738) literally (case sensitive)
Match a single character present in the list below
[\r\n]
(?2)
recurses the 2nd subpattern
} matches the character } with index 12510 (7D16 or 1758) literally (case sensitive)
Global pattern flags
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
g

Test String

Regex Debugger

Please wait while your expression is being debugged...