Could I please get some help with coverting some PHP code to jQuery/JavaScript? What I want is a simple BBCode to HTML converter.
Here is the PHP code. I want to achieve the same thing using jQuery/JavaScript.
$str = htmlentities($str);
// The array of regex patterns to look for
$format_search = array(
'#\[b\](.*?)\[/b\]#is',
'#\[i\](.*?)\[/i\]#is',
'#\[u\](.*?)\[/u\]#is',
);
// The matching array of strings to replace matches with
$format_replace = array(
'<strong>$1</strong>',
'<em>$1</em>',
'<span style="text-decoration: underline;">$1</span>',
);
// Perform the actual conversion
$str = preg_replace($format_search, $format_replace, $str);
Thanks for your help!
Looks ALMOST like you just need to change
#to/andistoigbut I also had to change/bto\/bLive Demo
Other Live Demo