Regular expressions: recursive patterns and callouts

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carlos

    #1

    Regular expressions: recursive patterns and callouts

    Hi!
    I think two extensions to re could be really powerful in aiding to
    match non regular strings -for example those containing parens nested
    up to an arbitrary depth- but without a significative performance loss,
    although I'm not at all sure at this last point. One of these features
    is re nesting; I don't mean nesting some strings and then compiling the
    composed re, but to include -possibly recursive- references to other
    re's. The second feature is the ability to add callout points in a re,
    so external functions would be called when the matcher reaches those
    points to validate the current matched prefix or even to do some
    arbitrary further matching of its own, advancing the pattern position.
    pcre implements similar features with its (?CN) callout and (?N)
    recursive patterns mechanisms.
    Are the above or equivalent features planned for future python
    releases?
    Do you know of some extension package which provide them or at least
    pcre compatible res?
    Thank you in advance,
    Carlos

  • Paul McGuire

    #2
    Re: Regular expressions: recursive patterns and callouts

    "Carlos" <carlosjosepita @gmail.com> wrote in message
    news:1137876890 .715521.292280@ f14g2000cwb.goo glegroups.com.. .[color=blue]
    > Hi!
    > I think two extensions to re could be really powerful in aiding to
    > match non regular strings -for example those containing parens nested
    > up to an arbitrary depth- but without a significative performance loss,
    > although I'm not at all sure at this last point. One of these features
    > is re nesting; I don't mean nesting some strings and then compiling the
    > composed re, but to include -possibly recursive- references to other
    > re's. The second feature is the ability to add callout points in a re,
    > so external functions would be called when the matcher reaches those
    > points to validate the current matched prefix or even to do some
    > arbitrary further matching of its own, advancing the pattern position.
    > pcre implements similar features with its (?CN) callout and (?N)
    > recursive patterns mechanisms.
    > Are the above or equivalent features planned for future python
    > releases?
    > Do you know of some extension package which provide them or at least
    > pcre compatible res?
    > Thank you in advance,
    > Carlos
    >[/color]

    Pyparsing supports both parse-time callouts (called "parse actions") and
    recursive grammar definitions.

    Download pyparsing at http://pyparsing.sourceforge.net.

    -- Paul


    Comment

    Working...