Flashで文字置換

Flash-jpで検索をかけていたら文字置換する素敵な関数があったのでカキコ!

//-------------------------------------------//
//convSentence(変換する文字列, 検索する文字, 置換する文字)
this.convSentence = function (theStc, oldKey, convKey) {
 var sentence_array = new Array();
 sentence_array = theStc.split(oldKey);
 return sentence_array.join(convKey);
};
//テキストノードの中身が下記のような状態とします。
outstr_str = "テキストがはいります\\nここで改行";

outstr_str = convSentence(outstr_str, "\\n", "\n");
trace('outstr_str=' + outstr_str);
//-------------------------------------------//
スポンサーリンク

スポンサーリンク