Java Program to Remove HTTP or HTTPS Protocol From URL Using Regular Expression
import java.net.URL;
public class test
{
public static void main(String[] args)
{
try {
URL url = new URL(args[0]);
String protocol = url.getProtocol();
String result = args[0].replaceFirst(protocol + ":", "");
if (result.startsWith("//"))
{
result = result.substring(2);
}
System.out.println(result);
} catch (Exception e) {
System.out.println(e);
}
}
}
String myString = "http://www.abc.com";
myString.replace("http://","").replace("http:// www.","").replace("www.","");