From: Simon Strandgaard Date: 2004-05-15T01:09:37+09:00 Subject: Re: Regexp Error? On Sat, 15 May 2004 01:02:48 +0900 Guillaume Marcais wrote: > On Fri, 2004-05-14 at 11:47, Simon Strandgaard wrote: > > > > my engine uses loop-detection, it thus outputs more desired results. > > http://raa.ruby-lang.org/list.rhtml?name=regexp > > > > For instance my engine outputs > > /a(a|)*/ ~= 'aaab' -> ['aaa', 'a'] > > /a(|ab)*b/ ~= 'aaabbb' -> ['aabb', 'ab'] > > /x(y?)*z/ ~= 'xyz' -> ['xyz', 'y'] > > /x(y{0,2})*z/ ~= 'xyz' -> ['xyz', 'y'] > > If you try the same examples with Gnu or Oniguruma, you will see the last elements > > are empty, I guess this is because they use the empty-token concept. > > > > Huh? False advertisement? > > [gus@comp tmp]$ cat regexp.rb > p /a(a|)*/.match('aaab').to_a > p /a(|ab)*b/.match('aaabbb').to_a > p /x(y?)*z/.match('xyz').to_a > p /x(y{0,2})*z/.match('xyz').to_a > [gus@comp tmp]$ ruby regexp.rb > ["aaa", "a"] > ["aabb", "ab"] > ["xyz", "y"] > ["xyz", "y"] > [gus@comp tmp]$ ruby -v > ruby 1.8.1 (2004-03-31) [i586-linux-gnu] > I am sorry about the false statement.. however on Oniguruma (the future) it true server> cat a.rb p /a(a|)*/.match('aaab').to_a p /a(|ab)*b/.match('aaabbb').to_a p /x(y?)*z/.match('xyz').to_a p /x(y{0,2})*z/.match('xyz').to_a server> ruby -v a.rb ruby 1.9.0 (2004-04-16) [i386-freebsd5.1] a.rb:1: warning: ambiguous first argument; put parentheses or even spaces a.rb:2: warning: ambiguous first argument; put parentheses or even spaces a.rb:3: warning: ambiguous first argument; put parentheses or even spaces a.rb:4: warning: ambiguous first argument; put parentheses or even spaces ["aaa", ""] ["aabb", ""] ["xyz", ""] ["xyz", ""] server> -- Simon Strandgaard