From: Robert Klemme Date: 2007-08-02T07:04:58+09:00 Subject: Re: Multiple matching with ()* On 31.07.2007 17:18, Alessandro Re wrote: > Thanks, this is an interesting solution! > > On 7/31/07, Robert Klemme wrote: >> 2007/7/31, Alessandro Re : >>> Mh well, to me it seems a normal regex processing (i mean, it *should* >>> require only one instruction, since this pattern can be read with just >>> one regex, even if ruby doesn't allow it... but it would be really >>> bad). >>> Anyway well, splitting it there are different ways to do it - thanks >>> for your sudjestion. >>> But if ruby make it possible with one call, i'd prefer to use it. >> irb(main):006:0> s="x1A2B3C4Dz" >> => "x1A2B3C4Dz" >> irb(main):007:0> s.scan /x(\d\w)*z/ >> => [["4D"]] >> irb(main):008:0> s.scan /x((?:\d\w)*?)z/ >> => [["1A2B3C4D"]] >> irb(main):009:0> s.scan(/x((?:\d\w)*?)z/).map {|a| a[0].scan(/\d\w/)} >> => [["1A", "2B", "3C", "4D"]] Give special attention to my usage of the reluctant qualifier which is mandatory if your input contains multiple begin end pairs. Kind regards robert PS: please do not top post.