Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace first occurrence of character in Android/Java?

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?

like image 367
sirvon Avatar asked Jan 03 '14 07:01

sirvon


1 Answers

String.replaceFirst will do the job.

String output = input.replaceFirst("s","");
like image 106
stinepike Avatar answered Nov 15 '22 08:11

stinepike