Resolving Quantifiers of Sub-Expression Quantifiers: ie: /( ( ( foo\w* )+? | ( fle\w+)* )...

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I recently think its possible the Regex engine does variable,
muti-phrase with inner quantifier, sub-expression matching, that
can be as well, enumerated with outer quantifiers to control the result.

I thought, "this can be very labor intensive to talk this out in English",
when designing a regex. But, an inner quantifier controlled, variable,
multi-phrase match, would be nice to be repeated by an outer quantifier capture
group instead of being picked up in pieces in a while loop for later assembly.

I understand the possible infinte loop scenario, anchor characters usually take
care of that.

My observations:

. The Regex engine will modify/optimize the submitted expression and the
resulting thing
might not be what you think.

. I have not seen in all the perldocs the subject of exponential matching, only
matching as it relates to quantifiers (ie: quantifiers of sub-expression
aren't covered).

The subject line is a crude example   /( ( ( foo\w* )+? | ( fle\w+)* ) ) )?
or   /( ( ( foo\w* )+? | ( fle\w+)* ) ) )+? bar/xg

But, I need to 'capture' a variable quantifier controlled phrase, repeating some
quantifier controlled sequenced amount, in a 'single' capture.

Not too hard of a concept. I've always wanted/needed to do this, but never had
sucess until today, where I did it in a very limited/sparce regex. I need to
this more.

My big question is I need some confirmation if this is right and possible, and
deep it can go.

Lets assume the Regex engine doesen't talk in English to itself when it
the expression. How does it resolve inner expression groups with quantifiers,
with outer
expression quantifiers?

Is there a formula, given inner vs. outer quantifiers, that shows the resultant
and or optimized expression?

Just asking, no need to say "look at the Regex engine code". I'm not being paid
to do that.

Hey, nice web site!

Site Timeline