i am trying to replace string that is matched
see example bellow
<?php
$str="this is going to bold [[this]]";
echo preg_replace("/[[(.*)]]+/i","<b>$1</b>",$str);
?>
So the output will look like this
this is going to bold this
Edit:
<?php
$str="bhai bhai *that* -wow- perfect";
$find[0]="/*(.+)*/i";
$find[1]="/-(.+)-/i";
$rep[0]="<b>$1</b>";
$rep[1]="<i>$1</i>";
echo preg_replace($find,$rep,$str);
?>
This is showing warning
Warning: preg_replace() [function.preg-replace]: Compilation failed: nothing to repeat at offset 0 in C:\xampp\htdocs\page.php on line 7
Try this :
Output :
Hint :
[and]characters are considered special, so you’ll have to escape them (like :\[,\]).UPDATE :