Wayne Blair wrote:
> 
> ----- Original Message -----
> From: "Stephen White" <spwhite / chariot.net.au>
> To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
> Sent: Tuesday, June 05, 2001 11:27 AM
> Subject: [ruby-talk:16237] Re: String#scan strange behavior
> 
> > On Wed, 6 Jun 2001, Wayne Blair wrote:
> >
> > > aString="one two three"
> > > matches = []
> > > regexp = /(\w)+/  # current scan would return [["e"], ["o"], ["e"]]
> > > aString.simpleScan(regexp) # => ["one", "two", "three"]
> >
> > Already seems to be that way if you don't use sub-expressions.
> >
> >   irb(main):006:0> "one two three".scan(/\w+/)
> >   ["one", "two", "three"]
> >
> > Works for me anyway. :)
> 
> Right, but if you have to use a subexpression, you are out of luck, for
> example when you want to match between 2 quotes but allow for escaped
> quotes:
> 
> /"(\\"|[^"])*"/
> 

At least you can still use the (?: form, which
gives you the benefit of grouping without the side effects.

regexp = /(?:\w)+/

or

/"(?:\\"|[^"])*"/


Guy N. Hurst


-- 
HurstLinks Web Development    http://www.hurstlinks.com/
Norfolk, VA  23510            (757)623-9688 FAX 623-0433
PHP/MySQL - Ruby/Perl - HTML/Javascript