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
/
(--([A-z\-]*?):(?<!--rgb:)).*?;
/
gm
1st Capturing Group
(--([A-z\-]*?):(?<!--rgb:))
--
matches the characters -- literally (case sensitive)
2nd Capturing Group
([A-z\-]*?)
Match a single character present in the list below
[A-z\-]
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
A-z matches a single character in the range between A (index 65) and z (index 122) (case sensitive)
\- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
: matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
Negative Lookbehind
(?<!--rgb:)
Assert that the Regex below does not match
--rgb:
matches the characters --rgb: literally (case sensitive)
.
matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
; matches the character ; with index 5910 (3B16 or 738) literally (case sensitive)
Global pattern flags
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gm

Test String

Substitution

Processing...