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
/
(?:(?:X.*Y)|(?:Y.*X))(.*)(?:Z)
/
g
Non-capturing group
(?:(?:X.*Y)|(?:Y.*X))
1st Alternative
(?:X.*Y)
Non-capturing group
(?:X.*Y)
X matches the character X with index 8810 (5816 or 1308) literally (case sensitive)
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Y matches the character Y with index 8910 (5916 or 1318) literally (case sensitive)
2nd Alternative
(?:Y.*X)
Non-capturing group
(?:Y.*X)
Y matches the character Y with index 8910 (5916 or 1318) literally (case sensitive)
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
X matches the character X with index 8810 (5816 or 1308) literally (case sensitive)
1st Capturing Group
(.*)
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Non-capturing group
(?:Z)
Z matches the character Z with index 9010 (5A16 or 1328) 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