From: dblack@... Date: 2002-11-15T22:24:27+09:00 Subject: Re: Regexp: What does //o do? Hi -- On Fri, 15 Nov 2002, Jim Freeze wrote: > On Friday, 15 November 2002 at 15:23:16 +0900, nobu.nokada@softhome.net wrote: > > Hi, > > > > At Fri, 15 Nov 2002 15:02:51 +0900, > > Jim Freeze wrote: > > > In a regex, what is the /o for (as opposed to n, i or g)? > > > > > > EG > > > re = /\A\s+/o > > > > This o has no meanings. It's usefull with interpolation. > > > > ['\A\s+', '\S+\z'].map {|s| /#{s}/} # => [/\A\s+/, /\S+\z/] > > ['\A\s+', '\S+\z'].map {|s| /#{s}/o} # => [/\A\s+/, /\A\s+/] > > > > I'm confused. Why does it affect the map iterator? > > ['a','b'].map {|s| /#{s}/o} # => [/a/,/a/] I think what's happening is that the /o causes the regex to be compiled only once, and in this case that sort of freezes it with respect to the further iterations. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav