views:

26

answers:

1

Code:

 var myPattern:RegExp = /\"/;

 trace(a.replace(myPattern, "\\\""));

<TEXTFORMAT LEADING=\"2"><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="10" COLOR="#0B333C" LETTERSPACING="0" KERNING="0">sdfdsfdsf</FONT></P></TEXTFORMAT>

above im using that regular expression to escape the " in the string. however it only does it for the first "

What am I doing wrong?

+3  A: 

You need to specify the global flag. See the docs for the replace method.

 var myPattern:RegExp = /\"/g;
tvanfosson