I've a function wich replace caracters in PHP :
$texte = preg_replace('`\[math\](.+)\[/math\]`isU', '\( $1 \)', $texte);
But I would allow the \
because my strings look like that : \frac{5}{2 \sqrt{5} } x_{k}
EDIT 1 :
For example, the user write the following BBcode : [math] \frac{5}{2 \sqrt{5} } x_{k} [math]
it will be translated in HTML by : \( \frac{5}{2 \sqrt{5} } x_{k} \)
EDIT 2 : This is the function :
$result = preg_replace('`\[math\](.*)\[/math\]`isU', '\( $1 \)', $text);
With $text = "[math] \frac{5}{2 \sqrt{5} } x_{k} [/math]";
It returns \( frac{5}{2 sqrt{5} } x_{k} \)
The \
has disappeared.
Louis