Here goes the function based on Zak's resonse 2 days ago:
function isMatch ($tokList,$str) {
$tok=strtok($tokList,"|");
while ($tok) {
if ( ereg ( '(([A-Z][A-Za-z]* )*($tok)
([A-Z][A-Za-z]* )*)',$str,$reg)) {
$tmp_str=$reg[1].$reg[2].$reg[3];
return ($tmp_str);
}
$tok=strtok("|");
}
return (NULL);
}
It is an attempt to get all the words starting with Cap around a Token,
including
the Token ($tok).
So, if called as in
$returnVal=isMatch($tokStr,$searchStr);
where $tokStr is "Junior|Senior|Specialist";
and $searchStr is "I am a Word Processing Specialist from New York"
$returnVal should be "Word Processing Specialist"
The function works if I replace $tok in the ereg() with a static literal
string "Specialist".
So, ereg (...(Specialist) ([A-Z][A-Za-z].. works, but does not work
when token is
made a variable.
I think I must be doing something silly!
--
PHP 3 Mailing List <http://www.php.net/>
To unsubscribe, send an empty message to php3-uns...@lists.php.net
To subscribe to the digest, e-mail: php3-diges...@lists.php.net
To search the mailing list archive, go to: http://www.php.net/mailsearch.php3
To contact the list administrators, e-mail: php-lis...@lists.php.net
If this is your exact code, then you should double check the braces in your
regular expression. Try using print_r or var_dump to show you the entire
contents of $reg.
HTH,
Zak