On Tuesday, March 30, 2010, Dmitry Belayev wrote: > Then why first .* is greedy and last one is not? The last one *is* greedy. When he adds it into his regexp, it matches the entire rest of the string. Regexp ".*foo(...)" matches "123foobar". Regexp ".*foo(...).*" matches "123foobar456".