[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:02297] Re: Multiple assignment of pattern match results.

From: matz@... (Yukihiro Matsumoto)
Date: 2000-03-31 13:59:09 UTC
List: ruby-talk #2297
Hi,

In message "[ruby-talk:02277] Re: Multiple assignment of pattern match results."
    on 00/03/30, mrilu <mrilu@ale.cx> 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.

In This Thread

Prev Next