I haven’t tried this in Dynatrace but it certainly works in regular regex. It assumes that all URLs will contain either HTTP or HTTPS and ends in a valid TLD between 2 and 63 characters.
You’re not going to be able to isolate the cleanup rule to just .it and .com because of the lack of lookahead in the regex engine. The following will get you the string between the first and second period: