I'm trying to replace the backslashes of the url/path to get the file name of the swf:
var path:String = "C:\Test\myswf.swf"
var swfURL:String = path.replace(/\\/gi, "/");
var swfFileName:String = path.slice(path.lastIndexOf("/")+1, path.length).replace(".swf", "");
But it doesn't works. The response is: 'C:Testmyswf.swf'. It's doesn't replace the string path. How can i do it?
我认为您可能需要在URL字符串中转义反斜杠:
var path:String = "C:\\Test\\myswf.swf"
Try this regex:
\\([^\\.]+)\.
Then get $1
I've managed to solve this problem by "performing crazy" with the code below:
var reg:RegExp = new RegExp("\\d"+stage.loaderInfo.url, "gi");
var idswf:String = reg.toString().replace(/\\/g, "/");
idswf = idswf.split("/")[idswf.split("/").length-2].replace(".swf", "");
It may not be the best solution, but it worked well for me and can work for other people...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.