Resolving Quantifiers of Sub-Expression Quantifiers: ie: /( ( ( foo\w* )+? | ( fle\w+)* ){0,5} ) )?

S

sln

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 linear
matching as it relates to quantifiers (ie: quantifiers of sub-expression quantifiers
aren't covered).

The subject line is a crude example /( ( ( foo\w* )+? | ( fle\w+)* ){0,5} ) )? bar/xg;
or /( ( ( foo\w* )+? | ( fle\w+)* ){0,5} ) )+? 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 any
sucess until today, where I did it in a very limited/sparce regex. I need to understand
this more.

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

Lets assume the Regex engine doesen't talk in English to itself when it parses/optimizes
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 quantifier
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!
-sln
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top