I know it’s simple, but I want a nice method. How from url string like:
/en/something/123/foo/
get
/something/123/foo/
?
It means, I want to remove first level (prefix).
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If it’s always three characters long:
If it can be variable-length, using only string/list operations:
Or using regex:
I would probably use the last method. If you need to do this a lot (e.g. in a loop), consider compiling the regex using
re.compile()to speed it up.