也许,我们并不需要一个preg_replace和strpos就足够了:$text = 'some word before then note: and some words after';$word = "note:";if (strpos($text, $word) !== false) { echo "YAAAY {$word} found in position: " . strpos($text, $word);}输出YAAAY note: found in position: 22