/ Published in: ActionScript 3
This function takes a string and returns a copy with all occurrences of http:// and https:// removed. The string, "Please visit http://example.com to find out more" would convert to "Please visit example.com to find out more". Generally this is more compact as the http:// is redundant when you are obviously referring to a URL.
Optionally, this function can also strip the www subdomain by passing true as the second parameter. It's set to false by default as example.com and www.example.com could theoretically contain different websites.
Expand |
Embed | Plain Text
function stripHttp(string:String, stripWWW:Boolean = false):String { var s:String = string; var regexp:RegExp = new RegExp(!stripWWW ? "https*:\/\/" : "https*:\/\/(www\.)*", "ig"); return s.replace(regexp, ""); }
You need to login to post a comment.
