Return to Snippet

Revision: 44087
at April 6, 2011 02:18 by hejaaa


Updated Code
// with protocol
var url:String = "http://www.domain.com/?value=test&message=debug";
var reg:RegExp = /([a-z]*:\/\/)?([a-z-_]*)?.?[a-z-_]*.[a-z]*/;
trace(url.match(reg)[0]); // http://www.domain.com

// without base protocol
var url:String = "http://www.domain.com/?value=test&message=debug";
var reg:RegExp = /[^https:\/\/]([a-z-_]*)?.?[a-z-_]*.[a-z]*/;
trace(url.match(reg)[0]); // www.domain.com

Revision: 44086
at April 6, 2011 01:54 by hejaaa


Initial Code
var url:String = "http://www.domain.com/?value=test&message=debug";
var reg:RegExp = /([a-z]*:\/\/)?([a-z-_]*)?.?[a-z-_]*.[a-z]*/;
trace(url.match(reg)[0]);

Initial URL

                                

Initial Description

                                

Initial Title
Extract domain name with RegExp

Initial Tags
regexp

Initial Language
ActionScript 3