I have a function which is containing multiple REGEX. Here is my function:
function generate($str) {
$str = preg_replace(/\*\*(.*?)\*\*/, "<b>$1</b>", $str);
$str = preg_replace(/__(.*?)__/, "<u>$1</u>", $str);
$str = preg_replace(/\*(.*?)\*/, "<i>$1</i>", $str);
$str = preg_replace(/--(.*?)--/, "<del>$1</del>", $str);
$str = preg_replace(/`(.*?)`/, "<code>$1</code>", $str);
return $str;
}
Now I want to know is this ^ the standard way? Overwriting several times on one variable? Is there any better approach?