From: GrzechG Date: 2007-06-10T21:25:05+09:00 Subject: Re: regex: get the first match > I want to parse a tagged string like this: "this ismy > string" > > i am doing: > >>> "this ismy string".scan(/(.*)<\/i>/) > => [["this ismy string"]] > > What i want is a regex that will return the *first* segment that > matches. > in the above case -> [["this is", "my string"]] The solution is : "this ismy string".scan(/(.*?)<\/i>/) => [["this is"], ["my string"]] The regexp scope is default maximum as is possible to find. If you use '?' character you minimze the scope. (.*?) instead of (.*) and the part of string don't be include into one result. Regards, Grzegorz Golebiowski