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
"
((?!\[)\w+(?=\]))
"
gi
1st Capturing Group
((?!\[)\w+(?=\]))
Negative Lookahead
(?!\[)
Assert that the Regex below does not match
\[ matches the character [ with index 9110 (5B16 or 1338) literally (case insensitive)
\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)
Positive Lookahead
(?=\])
Assert that the Regex below matches
\] matches the character ] with index 9310 (5D16 or 1358) literally (case insensitive)
Global pattern flags
g modifier: global. All matches (don't return after first match)
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"
"
gi

Test String