How do I do a preg_replace in Javascript?
I do the following in PHP, but would like to move it to Javascript.
<?php
$errors = '::Could not sign you into your account! ';
$errors .= '::Email or password error! ';
$errors = preg_replace('#\::(.+?)(?![^::])#','<div>$1</div>',$errors);
echo ($errors);
?>
I tried doing the same using JavaScript, but it just will not work somehow. Any thoughts on how this can be done?
var theString = "::Could not sign you into your account! :: Email or Password Error! ";
theString = theString.replace('#\::(.+?)(?![^::])#/g','<div>$1</div>');
alert(theString);