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
/
#[-_a-zA-Z][_a-zA-Z0-9-]*(?=[^}]*\{)
/
g
# matches the character # with index 3510 (2316 or 438) literally (case sensitive)
Match a single character present in the list below
[-_a-zA-Z]
- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
This hyphen is treated literally, which might be confusing for others. Consider escaping it or placing at the start or end of the class!
_ matches the character _ with index 9510 (5F16 or 1378) literally (case sensitive)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
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
[_a-zA-Z0-9-]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
_ matches the character _ with index 9510 (5F16 or 1378) literally (case sensitive)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
Positive Lookahead
(?=[^}]*\{)
Assert that the Regex below matches
Match a single character not 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 12510 (7D16 or 1758) literally (case sensitive)
\{ matches the character { with index 12310 (7B16 or 1738) 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...