String 替换url,但保留文件名(AS3)

String 替换url,但保留文件名(AS3),string,actionscript-3,url,String,Actionscript 3,Url,我从一个路径始终相同的网站获取了这些URL,只是文件名在更改 "http://www.swellmap.co.nz/style/img/weathericons/rain.png" 我的AS3代码,每天都在捕捉这个网站上的url(天气) 我想用我的图标替换每个图标 有没有办法替换路径但保留文件名?所以我只需要上传一个同名文件: 比如: Url = "http://www.swellmap.co.nz/style/img/weathericons/rain.png"; myUrl = "http

我从一个路径始终相同的网站获取了这些URL,只是文件名在更改

"http://www.swellmap.co.nz/style/img/weathericons/rain.png"
我的AS3代码,每天都在捕捉这个网站上的url(天气)

我想用我的图标替换每个图标

有没有办法替换路径但保留文件名?所以我只需要上传一个同名文件:

比如:

Url = "http://www.swellmap.co.nz/style/img/weathericons/rain.png";
myUrl = "http://www.mywebsite.nc/weather/";
Url.replace("http://www.swellmap.co.nz/style/img/weathericons/",myUrl); 
url_Icon= myUrl;
但如何判断“用文件名保留结尾?”


谢谢

为什么不定义自己的URL呢

像这样的东西应该可以做到:

var myNewURL:String = Url.replace("http://www.swellmap.co.nz/style/img/weathericons/", myUrl); 
如果图像名称前的零件不总是相同的:

// split the string by "/", this will result in ["http:", "", "www.swellmap.co.nz", "style", "img", "weathericons", "rain.png"]
// your imagename will be on the last position of the array
var urlSplit:Array = Url.split("/");

// get the image name from the last position of the array
var imageName:String = urlSplit[(urlSplit.length - 1)];

var newUrl:String = myUrl + imageName;