Definition Group(?(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)
) Comment: start DEFINE block
Comment: pre-define quant subroutine
Group quant(?<quant>many|some|five) manythe literal text many (case sensitive) somethe literal text some (case sensitive) fivethe literal text five (case sensitive) Comment: pre-define adj subroutine
Group adj(?<adj>blue|large|interesting) bluethe literal text blue (case sensitive) largethe literal text large (case sensitive) 3rd Alternativeinteresting interestingthe literal text interesting (case sensitive) Comment: pre-define object subroutine
Group object(?<object>cars|elephants|problems) carsthe literal text cars (case sensitive) elephantsthe literal text elephants (case sensitive) problemsthe literal text problems (case sensitive) Comment: pre-define noun_phrase subroutine
Group noun_phrase(?<noun_phrase>(?&quant)\ (?&adj)\ (?&object)) (?&quant)calls group quant as a subroutine
\ the literal (3210 / 408 / 2016)
(?&adj)calls group adj as a subroutine
\ the literal (3210 / 408 / 2016)
(?&object)calls group object as a subroutine
Comment: pre-define verb subroutine
Group verb(?<verb>borrow|solve|ressemble) borrowthe literal text borrow (case sensitive) solvethe literal text solve (case sensitive) ressemblethe literal text ressemble (case sensitive) Comment: end DEFINE block
Comment:#### The regex matching starts here #####
(?&noun_phrase)calls group noun_phrase as a subroutine
\ the literal (3210 / 408 / 2016)
(?&verb)calls group verb as a subroutine
\ the literal (3210 / 408 / 2016)
(?&noun_phrase)calls group noun_phrase as a subroutine
x modifier: extended. Ignores unescaped whitespace and comments outside character classes
g modifier: global. Finds all matches instead of stopping after the first