|
Posted by Rik on 05/11/06 03:27
strawberry wrote:
> Say I have a chunk of text and I know that somewhere in that chunk ot
> text is the phrase 'Next Week's Winning Number will be:', is there a
> way I can automatically grab the string immediately following?
>
> Any help greatly appreciated.
If you know the stringlength of the following string:
$occurance = strpos( $chunk, 'Next Week's Winning Number will be:');
$occurance += strlen('Next Week's Winning Number will be:');
$string = trim(substr($occurance, $lenght_of_searched_string));
If the lenght is undefined, use slower regular expression (allthough added
bonus is we can filter out whitespace-characters):
preg_match("/(?<=Next Week's Winning Number will be:)\s*([^\s]+?)\b/si",
$chunk, $match);
$string=$match[1];
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|