function find_next_word($text, $expression) {
// Use preg_quote to escape any special characters in the expression
$pattern = '/'. preg_quote($expression, '/') . '\s+(\w+)/';
if (preg_match($pattern, $text, $matches)) {
echo "The first word after '{$expression}' is: " . $matches[1] . "\n";
} else {
echo "No match found!\n";
}
}
$text = "The quick brown fox jumps over the lazy dog.";
$expression = "fox";
find_next_word($text, $expression);
/*
run:
The first word after 'fox' is: jumps
*/