.replace()无法正常工作

vin*_*ent 2 actionscript-3

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

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

cdh*_*wie 5

试试这个:

image = image.replace(/ /g, "_");
Run Code Online (Sandbox Code Playgroud)