.replace()无法正常工作

时间:2011-01-03 11:01:36

标签: actionscript-3

我有一个我想转换的字符串。

字符串是图片,内容为:Gone in 60 seconds 我需要的是以下内容:Gone_in_60_seconds 但是当我尝试:image = image.replace(" ","_"); 结果是:Gone_in 60 seconds 所以只有第一个空间被替换。 我如何将所有空格转换为下划线?

1 个答案:

答案 0 :(得分:5)

试试这个:

image = image.replace(/ /g, "_");
相关问题