Roger's solution is clearly better than what i'm about to suggest, but you can also limit the positions with your regex.. in this case something like /^.{10,20}hello world/si since, for 'hello world' to be in the first 30 characters it must not have more than 20 chars (i might have counted wrong by one) preceeding it, but there must be at least 10 before it.
Comment on Re: Applying a regex to part of a string
This one seems to have the least side effects, i.e.
I don't have to extract anything before, and the regex will
take care of failing when the pattern is not in the wanted
position.