From: "Jesús Gabriel y Galán" Date: 2008-11-19T22:18:49+09:00 Subject: Re: RegExp problem On Wed, Nov 19, 2008 at 1:01 PM, Florian Gilcher wrote: > Because you could get problems when you have things like this: > > "foo@fooo@bar@batz@foo" > > you rely on the the behaviour of the dot. Meaning: yours matches > > fooo@bar@batz > > Thus, it ignores all inner delimiters. Well, with the correction, it doesn't anymore: irb(main):071:0> "foo@fooo@bar@batz@foo".match(/([#{delimiter}])(.*?)\1/)[2] => "fooo" > In any case, mine matches: > > [["fooo"],["batz"]] #String#scan output > irb(main):072:0> "foo@fooo@bar@batz@foo".scan(/([#{delimiter}])(.*?)\1/) => [["@", "fooo"], ["@", "batz"]] > Depending on how the dot is treated (greediness etc.), yours > could also have other interpretations (like mine) while mine is clearer in > that respect. Well, obviously this only works as expected if you use the non-greedy version. But I understand what you mean about being clearer, more explicit. > In a simple case with only 2 delimiters, it doesn't matter. With more delimiters present in the string, mine works too. Thanks, Jesus.