how can I get the protocol and the domain form a string?
I think I should use regex for this?
Is this correct or is there a better solution?
If this is correct what should the regex code look like?
E.g.
I have the following URL: http://www.somedomain.com/page/subpage
And I would like to get: http://www.somedomain.com
Some more example URL's: https://www.somedomain.com/page/subpage (https://www.somedomain.com) or http://somedomain.com/page/subpage (http://somedomain.com) or http://test.domain.com/page/subpage (http://test.domain.com)
Thanks!