在Flex 3中,我有一个类似
的字符串var s:String = "http://www.abc.com/dump/one.htm#figure1"
//Want to parse this string and get the filename one.htm
我是flex的新手,尝试在谷歌搜索它,但没有得到任何解决方案。
答案 0 :(得分:3)
var s:String = "http://www.abc.com/dump/one.htm#figure1"
var arr:Array=s.split("/");
var s2:String = arr[arr.length-1];
var s3 = s2.split("#")[0];
var s4 = s3.split("?")[0];
//s4 is the string you need.
//no matter what u try, this code will never break.
试试看,告诉我们。
答案 1 :(得分:1)
var fileWithExtension:RegExp = /(?<=\/)(\w+)((\.\w+(?=\?))|(\.\w+)$)/g;
trace("file name with extension =", url.match(fileWithExtension));
// file name with extension = fileName.fileExtension
URI语法:http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax