PHP - str_replace替代无法评估是否找不到

I'm not able to find any method to replace pieces of string without evaluation of replacement if searched phrase is not found.

e.g.

public static function replaceAlias($text) {
  ...
  $newtext = str_replace('%noreg%', Db::querySingle('SELECT COUNT(*) AS `noreg` FROM `vk-users`')['noreg'], $text);
  ...
return $newtext;
}

Query on db is used each time when replaceAlias is called even if %noreg% is not found and when I have many str_replace commands, it gives a big, unnecessary pressure on database

I know that I can use if conditions to search if alias is used in the $text and then replace it, but now I only want to know if there is any nice and quick solution, which is already built in php?