From: dblack@... Date: 2006-11-06T10:48:49+09:00 Subject: Re: Ugly code - suggestions? HI -- On Mon, 6 Nov 2006, greg wrote: > couple of ideas for you- didn't this out though > nil.to_s #=> "" > no need to re-scan a match if you can use $1, $2, etc The reason is that you might have more than one ;\d+ sequence, and the scan operation with captures will only give you the last one: >> p "abc;31;32;33".scan(/abc(;\d+)*/) => [[";33"]] I don't know whether the named captures in oniguruma might help here.... David -- David A. Black | dblack@wobblini.net Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org