Your second match doesn't work for the string "hello world ....hello world". It'll match the first "hello world" and decide it's out of bounds, without seeing the second "hello world" within the bounds.
Comment on Re: Applying a regex to part of a string