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

Discussion in 'Perl Misc' started by sln@netherlands.com, Feb 18, 2009.

  1. Guest

    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
     
    , Feb 18, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    383
    John Roth
    Jul 29, 2005
  2. Replies:
    1
    Views:
    348
  3. NeoGeoSNK
    Replies:
    4
    Views:
    3,684
    Joshua Cranmer
    Mar 3, 2008
  4. .rhavin grobert

    vector: Foo[5] == ((foo*)Foo) + 5 ?

    .rhavin grobert, Sep 23, 2008, in forum: C++
    Replies:
    4
    Views:
    394
    JaredGrubb
    Sep 24, 2008
  5. Replies:
    4
    Views:
    146
    Thomas 'PointedEars' Lahn
    Dec 23, 2007
Loading...

Share This Page