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
"
`(?P<class>\w+)>>(?P<method>(?:\w+):?(?:(?:(?:\w+):)+))`
"
` matches the character ` with index 9610 (6016 or 1408) literally (case sensitive)
Named Capture Group class
(?P<class>\w+)
\w
matches any word character (equivalent to [a-zA-Z0-9_])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
>>
matches the characters >> literally (case sensitive)
Named Capture Group method
(?P<method>(?:\w+):?(?:(?:(?:\w+):)+))
Non-capturing group
(?:\w+)
\w
matches any word character (equivalent to [a-zA-Z0-9_])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
:
matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
Non-capturing group
(?:(?:(?:\w+):)+)
Non-capturing group
(?:(?:\w+):)+
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
Non-capturing group
(?:\w+)
\w
matches any word character (equivalent to [a-zA-Z0-9_])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
: matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
` matches the character ` with index 9610 (6016 or 1408) literally (case sensitive)
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"

Test String