in reply to Conditional Regex

You may be able to use a canned regex (See Regexp::Common and Regexp::Common::URI::http). The example in Re: Extracting a domain name from a url might help. Cheers.