I would like to take the 's' out of http.
https://joy.tothewor.ld/today/and/tommorrow
http://joy.tothewor.ld/today/and/tommorrow
What's the fastest/less expensive way?
substring, string builder, something newer in Android's SDK?
String.replaceFirst is heavyweight
public String replaceFirst(String regex, String replacement) {
return Pattern.compile(regex).matcher(this).replaceFirst(replacement);
}
this is the fastest way
str = str.substring(0, 4) + s.substring(5);
4. But if you know beforehand that str starts with "https" and is supposed to be changed to "http…", it might be even faster to say str = "http" + s.substring(5);
if(string.startsWith("https:")) string = "http"+string.substring(5);