Need php parsing help (egrep?)
Posted: Thu Dec 18, 2003 12:44 pm
Hi,
I want to be able to extract a word out of a string. Here is an example:
I want to extract the word "data". The example I posted works, but it's because I know that there are 2 "want" and "ok" substrings.
Assuming I don't know that the word is "data", how can I grab any text between the last "want" and the first "ok"?
Thanks,
Grant
I want to be able to extract a word out of a string. Here is an example:
Code: Select all
$teststring = "All I want want data ok ok";
$temp = ereg("want (.*) ok", $teststring, $content);
$temp = ereg_replace("<br>", "<br>", $contentї1]);
$temp = ereg("want (.*) ok", $temp, $content);
$temp = ereg_replace("<br>", "<br>", $contentї1]);
echo "Extracted data: $temp";Assuming I don't know that the word is "data", how can I grab any text between the last "want" and the first "ok"?
Thanks,
Grant