开发者

replacing backslashes with forward slashes in actionscript

var aText:String = "C:\\folder\\folder\\file";
var filterVal:String = aText.toLowerCase().replace( /\//g, '/');
t开发者_高级运维race( aText );
trace( filterVal );

results as:

C:\folder\folder\file
c:\folder\folder\file

this code was based on this site and nascent regex skills.

What am I doing wrong? Thank you.


you are doing it wrong, what you seem want \is:

var filterVal:String = aText.toLowerCase().replace( /\\/g, '/');

The initial and ending '/' delimit the Regular Expression. What is inside (\\) is what you are searching for. Since it's a backslash, you need to escape it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜