From: Brian Candler Date: 2009-09-02T23:50:52+09:00 Subject: Re: regex issue confusing You may find \b useful: it means "match a word boundary" without actually consuming any characters. Your example starts with \s (match one space), so it wouldn't match #include right at the beginning of the file. But if I remember my C right, the #include has to be at the start of a line anyway. So perhaps you want: >> line = "#include " => "#include " >> line[/^\s*#include\s*["<]([^">]+)/, 1] => "stdio.h" HTH, Brian. -- Posted via http://www.ruby-forum.com/.