0

I would like to match the word mat($MPC) in my regex, but because of the parentheses it does'nt work.

Is there a way that I can classify the word as text and not as a regex expression.

$text = "1.5*mat($MPC)*AMOUV+NBSC";
$word = "mat($MPC)";
preg_replace('/\b'.$word.'\b/u','50',$text);

I'm not using str_replace because sometime I need to replace NBS or NBSC. So when I'm replacing it need to be a whole word.

Thank

Pierre-Luc Bolduc
  • 485
  • 1
  • 5
  • 18

0 Answers0