开发者

replacing backslashes with forward slashes in actionscript

开发者 https://www.devze.com 2022-12-19 15:51 出处:网络
var aText:String = \"C:\\\\folder\\\\folder\\\\file\"; var filterVal:String = aText.toLowerCase().replace( /\\//g, \'/\');
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

精彩评论

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