jQuery Data Type How to - Replace " ' " with " '' "








Question

We would like to know how to replace " ' " with " '' ".

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
<!--from   w  ww .  ja  v  a 2 s  . c  o m-->
        var temp = "this is a 'test";
        var replacement = temp.replace(/'/g, "''");
        document.writeln(replacement);
</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: