Mena
1
<?php
$string = ‘I want to replace this $p(x) = \frac {x} {\sigma^2} e^{\frac{{-x^2}}{2\sigma^2}}$ to image’;
$patterns = ‘/\$+[^a-zA-Z0-9]+[a-zA-Z0-9]\$/’;
echo “pattern”.$patterns.“<br>”;
$replacements = “<img src=‘err.png’/>”;
echo preg_replace($patterns, $replacements, $string);
?>
anybody is there to help me…
i want to replace the $p(x) = \frac {x} {\sigma^2} e^{\frac{{-x^2}}{2\sigma^2}}$ to image…
Mena
2
grt!.. Thankyou… It’s working…
r2d2
3
This works for me:
$patterns = '/\\$[^\\$]*\\$/';
Finds a $, followed by any number of characters that aren’t a $, followed by a $.
Cups
4
So, anything between 2 $ signs, and the $s themselves, you want to replace?
Mena
5
ya i have to replace total string $ to $ including ‘$’ sign to image