Hi, I was trying to escape quotes in a string and discovered a bug. According to documentation there are two uses of String.replace function. First uses a parameter of type string to search for a text to replace and should replace only first occurrence of the string. Second uses a regular expression param to search for a text to replace and should replace all occurrences of the regExp. Well run this xpage and try all three ways of replacing:
<?xml version="1.0" encoding="UTF-8"?><xp:view xmlns:xp=“http://www.ibm.com/xsp/core”>
<xp:text id="computedField1">
<xp:this.value><![CDATA[#{javascript:var input = "ahoj sv'ete kuk's";
var result = input.replace(/‘/, "\’");
//var result = input.replace(/‘/, "\\’");
//var result = input.replace(“'”, “\'”);
var ev = “var testVar ='”+result+“'”;
eval(ev);
return result;}]]></xp:this.value>
</xp:text>
</xp:view>