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
"
(?:(http|https)(://))
"
g
Non-capturing group
(?:(http|https)(://))
1st Capturing Group
(http|https)
1st Alternative
http
http
matches the characters http literally (case sensitive)
2nd Alternative
https
https
matches the characters https literally (case sensitive)
2nd Capturing Group
(://)
://
matches the characters :// 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

"
"
g

Test String