in reply to Re: Slicing a string on words
in thread Slicing a string on words

Doesn't seem to work: Given $window_start of 0, $window_size of 100, and $text_body of 'Testing news submission.', it gives 'news'.

It also seems to make....wait. Ok, I know where Testing is going and can fix that. It's not working on teh last word because there's no whitespace after it. Would changing \s+ to \s* work?

Replies are listed 'Best First'.
Re: Re: Re: Slicing a string on words
by dga (Hermit) on Aug 29, 2001 at 22:02 UTC

    I think it would be safest (and safe to assume) that a 1 Meg string will be stored in a file and terminated with some sort of CR and or LF and in fact the pattern match I have would require that to be the case. The pattern would get a lot more complex if you could end a string with a \S type of entity.

    However you have noticed a problem with the original code with a start of 0. I will update that bit.