0

suppose I have a string:

some_string = 'https://api.github.com/repos/username/repo-name'

How do I move from right to left and stop at the first occurrence of / such that what is returned will be repo-name?

1

2 Answers 2

1

you can do some_string.split("/")[-1]

Sign up to request clarification or add additional context in comments.

Comments

1
some_string.rfind("/")

will return the right-most index of a given character.

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.