Adam
Adam

Reputation: 9049

I am only able to replace the first quotation mark in my str

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?

Upvotes: 0

Views: 132

Answers (1)

tvanfosson
tvanfosson

Reputation: 532435

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

 var myPattern:RegExp = /\"/g;

Upvotes: 3

Related Questions