From: Glenn Jackman Date: 2009-09-02T22:30:12+09:00 Subject: Re: regex issue confusing At 2009-09-02 08:02AM, "Brian Candler" wrote: > Ahmet Kilic wrote: > > This is OK > > line[/\sclass\s(\w+)/, 1] > > but > > line[/\s#include\s(\w+)/, 1] > > this is not. > > > > why??? please help. > > "Not OK" by what definition? > > Try posting an irb transcript which demonstrates your problem with > sample data. It looks OK to me: > > >> line = "foo #include bar baz" > => "foo #include bar baz" > >> line[/\s#include\s(\w+)/, 1] > => "bar" require 'mind_reading' Perhaps the line is something like: #include in which case the angle bracket gets in the way. Ahmet, do you want: line[/\s*#include\s+['"<]?(\w+)/, 1] # => "stdio" ? -- Glenn Jackman Write a wise saying and your name will live forever. -- Anonymous