From: Steve Tuckner Date: 2002-02-07T02:20:27+09:00 Subject: RE: Regexp::Parser ported to Ruby...? This would be very interesting and a way to play with RegExp's in Ruby in ways that you currently can't. For example, I have wished for the following capability. "aab1db2ec5daaac3dc4e".scan(/((a+)(([bc])(\d)([de]))+)+/, Proc.new {|s,t| print "a=#{a},b=#{b},c=#{c}\n"}, Proc.new {|x,y,z| print "d=#{d},e=#{e},f=#{f}\n"}) would result in: x=b,y=1,z=d x=b,y=2,z=e x=c,y=5,z=d s=aa,t=b1db2ec5d x=c,y=3,z=d x=c,y=4,z=e s=aaa,t=c3dc4e The semantics behind this would be that for every repeating group (as well as the top level), there could be a proc that gets executed when that group matches. The arguments for the proc would be what matched for each group within that repeating group down to any repeating groups inside of this level repeating group. So in the above example, the first proc only gets two arguments, because the groups inside of the contained repeating group have no meaningful values (except possibly the values of the last match which I don't find very useful). For me this would be useful to parse output that is obviously computer generated output and has nesting inside of nesting. A real world example might be something like below. Weather Report ===== Midwest ====== Minneapolis, MN High: 32 Low: 15 Chicago, IL High: 45 Low: 32 ===== Southeast ===== Miami, FL High: 90 Low: 65 ...etc... Anyway what does everyone think of this idea. Does it seem useful to you? Steve Tuckner -----Original Message----- From: Jeff 'japhy' Pinyan [mailto:jeffp@crusoe.net] Sent: Wednesday, February 06, 2002 12:02 AM To: ruby-talk@ruby-lang.org Subject: Regexp::Parser ported to Ruby...? I'm writing a Perl module for the parsing and handling of regexes. It's useful for things like explaining the meaning of parts of the regex, adding debugging statements throughout the regex, supporting non-existent features, reversing the regex, and other weird things. Is there any interest in me porting this to Ruby? It'd be a good exercise for me, as I've not written much "real" Ruby, and this would be a good kick to the head. -- Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course.