From: Ross Bamford Date: 2005-12-15T07:03:34+09:00 Subject: Re: regular expressions question On Wed, 14 Dec 2005 21:34:52 -0000, ako... wrote: > thank you. this was just an example. in general, is it possible to get > a collection of captures for a group without having to write custom > code? > Have to admit I'm not exactly a regex wiz, but I imagine it can be done somehow. I assume you mean having a repeated capturing group append to an array any number of times? But, I still think scan is a good tool for the job, it can do any regexp anyway. I don't think a single regexp is really intended for doing variable numbers of captures anyway (?) ). irb(main):054:0> "ab c".scan(/\w|\s/) => ["a", "b", " ", "c"] or irb(main):052:0> "this is a test".scan(/\w+/) => ["this", "is", "a", "test"] or even irb(main):053:0> "this is a test".scan(/\w+|\s/) => ["this", " ", "is", " ", "a", " ", "test"] Cheers, Ross -- Ross Bamford - rosco@roscopeco.remove.co.uk "\e[1;31mL"