From: come Date: 2007-03-14T21:30:08+09:00 Subject: Re: ruby regex lookarounds? Hi, The syntax (?:re) isn't a lookbehind. It is a grouping form like (re) but without capture. So (?:(re)) is the same as (re). Off course, you could write something like (?:a(bc)), and you will get "bc" in $1, and not "abc". On 14 mar, 09:35, 7stud 7stud wrote: > I see what's going on. (?:ab) is not a grouping: (?: and ) do not form a > grouping that gets a $ variable. If I write it as (?:(ab)), then ab is > a grouping: > > irb(main):021:0> "abc" =~ /(?:(ab))(c)/ > => 0 > irb(main):022:0> $& > => "abc" > irb(main):023:0> $1 > => "ab" > irb(main):024:0> $2 > => "c" > irb(main):025:0> > > It still seems a little strange that $& contains the lookaround. > > -- > Posted viahttp://www.ruby-forum.com/.