From: Martin DeMello Date: 2007-07-25T02:35:26+09:00 Subject: Re: Regex Question On 7/24/07, Martin DeMello wrote: > your last question - (\w*)\1 matches the empty string. What the engine > does is match (\w+) against M, then \1 against another M which fails. > Likewise for Mi, Mis, Miss etc, till it hits the end and moves on to > i, is, iss... when it suddenly succeeds. Illustrative examples: Oops - Rob is right, of course - + being greedy, it tries \w+ = Mississippi first, then shrinks from there: >> show_regexp("MiMississippiMiMississippi", /(\w*)\1/) => "<>" martin