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
"
(?<=\[)(?!:scroll:)(?!\d+)(?P<title>[A-Z][\w\s\,\-\?\:\']+)(?=\])
"
g
Positive Lookbehind
(?<=\[)
Assert that the Regex below matches
\[ matches the character [ with index 9110 (5B16 or 1338) literally (case sensitive)
Negative Lookahead
(?!:scroll:)
Assert that the Regex below does not match
:scroll:
matches the characters :scroll: literally (case sensitive)
Negative Lookahead
(?!\d+)
Assert that the Regex below does not match
\d
matches a digit (equivalent to [0-9])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
Named Capture Group title
(?P<title>[A-Z][\w\s\,\-\?\:\']+)
Match a single character present in the list below
[A-Z]
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
Match a single character present in the list below
[\w\s\,\-\?\:\']
+ 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_])
\s matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\, matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
\- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
\? matches the character ? with index 6310 (3F16 or 778) literally (case sensitive)
\: matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
\' matches the character ' with index 3910 (2716 or 478) literally (case sensitive)
Positive Lookahead
(?=\])
Assert that the Regex below matches
\] matches the character ] with index 9310 (5D16 or 1358) 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.

Regular Expression
No Match

r"
"
g

Test String