[Minor Change Proposal]Allow back reference with nest level in Onigurumafor Ruby again

Discussion in 'Ruby' started by Wolfgang Nádasi-Donner, May 14, 2007.

  1. Hello dear Ruby folks!

    Nearly one year ago I asked K. Kosako for a new Oniguruma feature which will
    help to recognize plindrome sentences. It was an idea for an article series in
    Ruby-Mine, a german Ruby blog site, about pattern matching with Ruby using
    regular expressions.

    K. Kosako built a special new element, which is described in the History...

    -----------------------------------------------------------------
    2006/07/18: Version 4.2.0

    2006/07/18: [test] success in ruby 1.9.0 (2006-03-01) [i686-linux].
    2006/07/18: [new] (thanks Wolfgang Nadasi-Donner)
    add back reference with nest level.
    \k<name+n>, \k<name-n>
    -----------------------------------------------------------------

    ....and in the Oniguruma description...

    -----------------------------------------------------------------
    back reference with nest level

    \k<name+n> n: 0, 1, 2, ...
    \k<name-n> n: 0, 1, 2, ...
    \k'name+n' n: 0, 1, 2, ...
    \k'name-n' n: 0, 1, 2, ...

    Destinate relative nest level from back reference position.

    ex 1.

    /\A(?<a>|.|(?:(?<b>.)\g<a>\k<b+0>))\z/.match("reer")

    ex 2.

    r = Regexp.compile(<<'__REGEXP__'.strip, Regexp::EXTENDED)
    (?<element> \g<stag> \g<content>* \g<etag> ){0}
    (?<stag> < \g<name> \s* > ){0}
    (?<name> [a-zA-Z_:]+ ){0}
    (?<content> [^<&]+ (\g<element> | [^<&]+)* ){0}
    (?<etag> </ \k<name+1> >){0}
    \g<element>
    __REGEXP__

    p r.match('<foo>f<bar>bbb</bar>f</foo>').captures
    -----------------------------------------------------------------

    This feature disapeared for Ruby later on...

    -----------------------------------------------------------------
    2006/08/11: Version 4.2.3

    ....
    2006/08/07: [spec] move definition of USE_BACKREF_AT_LEVEL into NOT_RUBY.
    -----------------------------------------------------------------

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    My question is now - WHY?????

    I would like to see it workable for Ruby again, it can be useful - and - it is
    already there!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Wolfgang Nádasi-Donner
     
    Wolfgang Nádasi-Donner, May 14, 2007
    #1
    1. Advertising

  2. Re: [Minor Change Proposal]Allow back reference with nest level inOniguruma for Ruby again

    I have one question, because there is no reaction to this post:

    Is this here (comp.lang.ruby) the right place for discussions and "change
    proposals" for Oniguruma usage in Ruby 1.9?

    If this is not the case, please give me a hint where to place these texts.

    Thanks in advance, Wolfgang Nádasi-Donner
     
    Wolfgang Nádasi-Donner, May 15, 2007
    #2
    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. pabbu
    Replies:
    8
    Views:
    732
    Marc Boyer
    Nov 7, 2005
  2. Wolfgang Nádasi-Donner
    Replies:
    3
    Views:
    166
    Wolfgang Nádasi-Donner
    Jan 30, 2007
  3. Wolfgang Nádasi-Donner

    Minor Change Proposal for Classe 'UnboundMethod'

    Wolfgang Nádasi-Donner, Jan 19, 2007, in forum: Ruby
    Replies:
    0
    Views:
    126
    Wolfgang Nádasi-Donner
    Jan 19, 2007
  4. Wolfgang Nádasi-Donner

    Minor Change Proposal for Class 'Numeric'

    Wolfgang Nádasi-Donner, Jan 22, 2007, in forum: Ruby
    Replies:
    7
    Views:
    116
    Wolfgang Nádasi-Donner
    Jan 23, 2007
  5. Brent S. Elmer Ph.D.
    Replies:
    0
    Views:
    61
    Brent S. Elmer Ph.D.
    Apr 29, 2014
Loading...

Share This Page