0

I have the following string: https://dummycloud/image/fetch/f_webp,q_auto:best,w_1080,c_limit/auto/https://dummy.com/media/products/8/8/763160.jpg

And I am only interested in the this part that comes at the end: https://dummy.com/media/products/8/8/763160.jpg

I am using the following with StringBuilder

val url = imageUrl.substringAfterLast("https")

return StringBuilder()
    .append("https")
    .append(url)
    .toString()

Just wondering if there is a substringAfterLast that would keep the prefix https. As I have to use StringBuilder manually to append it from the extract string.

1
  • 4
    Btw why are you using a StringBuilder instead of just "https$url"? Commented Feb 11, 2022 at 17:58

1 Answer 1

4

You could use

imageUrl.substring(imageUrl.lastIndexOf(“https”));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.