【问题标题】:text replace using charcode in AS3在 AS3 中使用 charcode 替换文本
【发布时间】:2011-04-18 11:59:01
【问题描述】:

如何根据字符码替换文本?

【问题讨论】:

    标签: flash actionscript-3


    【解决方案1】:
    var charcode = 34; //example, put whatever here
    var char = String.fromCharCode(charcode);
    
    var string_to_edit = 'This is my string.';
    
    var new string = string_to_edit.replace(char, 'whatever you are replacing with');
    

    您可能必须将其设为使用 replace() 的模式,但我不这么认为。

    【讨论】:

    • 请注意,字符串在 Actionscript 中是不可变的。所以你不能真正改变一个字符串。在这种情况下,这意味着您必须将replace 返回的字符串重新分配给string_to_edit(或任何其他变量,如果需要)。
    • 我的错,已修复。是从臀部写的,没有检查过。
    • 这没关系,就目前而言,但它不是 AS3。您没有强制转换和/或范围变量等。
    猜你喜欢
    • 2012-11-27
    • 2014-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-17
    • 1970-01-01
    • 2011-11-25
    相关资源
    最近更新 更多