I have full link like this:
http://localhost:8080/suffix/rest/of/link
How to write regex in Java which will return only main part of url with suffix: http://localhost/suffix
and without: /rest/of/link
?
- possible protocols: http, https
- possible ports: many possibilities
I've assumed that I need to remove whole text after 3rd occurrence of '/'
mark (including).
I would like to do it as below, but I do not know regex well, can you help please how to write regex correctly?
String appUrl = fullRequestUrl.replaceAll("(.*\\/{2})", ""); //this removes 'http://' but this is not my case