var string:String = "something 'is' \\fishy here"; trace(string);//something 'is' \fishy here string = string.replace(/(['\\])/g,"\\$1"); trace(string);//something \'is\' \\fishy here