Question : How do I split an url to get the file-name

How do I split an url like http://www.mysite.com/myfirstpath/mysecondpath/somerandomfile.swf so I get a variable named  "somerandomfile"

What I'm interested in is to get the name of the file without the filetype and nomatter how many path there are to the name of the file.

Answer : How do I split an url to get the file-name

this should help
1:
2:
3:
4:
5:
6:
7:
		private function getFilename(myURL:String):String
		{
			var lastSlash:Number=myURL.lastIndexOf("/")+1; //get the beginning of filename after last "/"
			var lastDot:Number=myURL.lastIndexOf(".");//get the last . location, after our "/"
			if (lastDot < lastSlash) lastDot = myURL.length; //in case there's no "."	
			return (myURL.slice(lastSlash,lastDot));//cut out the part starting at after "/" and ending at "."
		}	 
Open in New Window Select All
Random Solutions  
 
programming4us programming4us