Regular Expressions 101

@regex101
Donate
Sponsor
Contact
Bug Reports & Feedback
Wiki
Whats new?

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python 2.7
  • Golang
  • Java 8

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
(?(DEFINE) # start DEFINE block # pre-define quant subroutine (?<quant>many|some|five) # pre-define adj subroutine (?<adj>blue|large|interesting) # pre-define object subroutine (?<object>cars|elephants|problems) # pre-define noun_phrase subroutine (?<noun_phrase>(?&quant)\ (?&adj)\ (?&object)) # pre-define verb subroutine (?<verb>borrow|solve|ressemble) ) # end DEFINE block ##### The regex matching starts here ##### (?&noun_phrase)\ (?&verb)\ (?&noun_phrase)
/
xg
Subpattern definition construct
(?(DEFINE) # start DEFINE block # pre-define quant subroutine (?<quant>many|some|five) # pre-define adj subroutine (?<adj>blue|large|interesting) # pre-define object subroutine (?<object>cars|elephants|problems) # pre-define noun_phrase subroutine (?<noun_phrase>(?&quant)\ (?&adj)\ (?&object)) # pre-define verb subroutine (?<verb>borrow|solve|ressemble) )
May only be used to define functions. No matching is done in this group.
Comment: start DEFINE block
Comment: pre-define quant subroutine
Named Capture Group quant
(?<quant>many|some|five)
1st Alternative
many
many matches the characters many literally (case sensitive)
2nd Alternative
some
some matches the characters some literally (case sensitive)
3rd Alternative
five
five matches the characters five literally (case sensitive)
Comment: pre-define adj subroutine
Named Capture Group adj
(?<adj>blue|large|interesting)
1st Alternative
blue
2nd Alternative
large
3rd Alternative
interesting
Comment: pre-define object subroutine
Named Capture Group object
(?<object>cars|elephants|problems)
Comment: pre-define noun_phrase subroutine
Named Capture Group noun_phrase
(?<noun_phrase>(?&quant)\ (?&adj)\ (?&object))
Comment: pre-define verb subroutine
Named Capture Group verb
(?<verb>borrow|solve|ressemble)
Comment: end DEFINE block
Comment: #### The regex matching starts here #####
(?&noun_phrase) recurses the subpattern named noun_phrase
\ matches the character literally (case sensitive)
(?&verb) recurses the subpattern named verb
\ matches the character literally (case sensitive)
(?&noun_phrase) recurses the subpattern named noun_phrase
Global pattern flags
x modifier: extended. Spaces and text after a # in the pattern are ignored
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

/
/
xg

Test String