Ah, left out a relevant bit of info: I need to preserve whitespace. So what I *really* need is the index of the end of the $window_start'th word, and the index of the ($window_start + $window_size)'th word.
And these are potentially 1 meg strings, so I'd like to avoid copies if possible.