如何在Javascript中执行preg_replace?
我在PHP中执行以下操作,但希望将其移至Javascript。
<?php
$errors = '::Could not sign you into your account! ';
$errors .= '::Email or password error! ';
$errors = preg_replace('#\::(.+?)(?![^::])#','<div>$1</div>',$errors);
echo ($errors);
?>
我尝试使用JavaScript做同样的事情,但它不会以某种方式工作。有关如何做到这一点的任何想法?
var theString = "::Could not sign you into your account! :: Email or Password Error! ";
theString = theString.replace('#\::(.+?)(?![^::])#/g','<div>$1</div>');
alert(theString);
答案 0 :(得分:3)
Javascript regexps主要不使用引号和SELECT * FROM (
SELECT COALESCE(ta.country, tb.country) as country, tc.region
FROM tb
FULL OUTER JOIN (
SELECT country, region FROM tablec
) tc ON tc.country = tb.country
FULL OUTER JOIN (
SELECT country, region FROM tablea
) ta ON ta.country = tb.country
) WHERE country IS NOT NULL AND region IS NOT NULL
:
COALESCE