正则表达式来从URL域正则表达式、URL

2023-09-08 13:50:21 作者:萌面大瞎

任何人都知道正则表达式的AS3来从URL中的域名? 例如:http://www.google.com/translate将得到http://www.google.com

Anyone knows the Regexp for AS3 to get the domain name from URL? E.g: "http://www.google.com/translate" will get "http://www.google.com"

推荐答案

有是与URI的处理中的的as3corelib 。也许你会想用滚动你自己的这个代替。

There's is a very complete utility class for dealing with URIs in as3corelib. Perhaps you might want to use this instead of rolling your own.

import com.adobe.net.URI;
var uri:URI = new URI("http://www.google.com/translate");
trace(uri.authority); // traces www.google.com