From: matz@... (Yukihiro Matsumoto) Date: 2000-03-31T22:59:09+09:00 Subject: [ruby-talk:02297] Re: Multiple assignment of pattern match results. Hi, In message "[ruby-talk:02277] Re: Multiple assignment of pattern match results." on 00/03/30, mrilu writes: |mrilu> |I think it's time for String.scan(pattern[, limit]), like split. |matz> Interesting. | |Is it interesting that scan(pattern,limit) might be useful or that me poor |stupid loser tend to think erratically consistently :) ? The former, seriously. |! result = rb_ary_new2(regs->num_regs); |! for (i=1; i < regs->num_regs; i++) { |! rb_ary_push(result, rb_reg_nth_match(i, match)); |! } |! return result; | |So I thought this could return an array from scan_once to rb_str_scan, |and there we will call possible iterator for every match. No, the code above put the matching subpatterns into an array, no iteration made. So no appearant performance penalty for |> t = u = v = nil |> x.scan(/(a+)[^ace]*(c+)[^e]*(e+)/) do |t,u,v| |> break |> end |One more thing. I don't know how things are done in other languages, but |for my eyes C-files that I got with Ruby seem to be crystal clear and |simple (umm. maybe I haven't looked hard enough - and don't look re.c :). Thanks. Probably eval.c, parse.y and regex.c are exceptions. :-) |I don't know if this is special feature of Ruby? Or are other scriptings |languages as crisp? Well, at least the sourcecode for Perl looks very cryptic, Python's looks better than that. matz.