I have a string:
x = "abc/xyz/foo/bar/foobar.mp3"
How to extract foobar out of it?
I have done it in this way:
import re
re.search(r'\/[a-z]+.mp3', x)
Although, I do not know how to extract the matched string without '.' and without '.mp3'.
I do not want to do Python splits, rplist, partition etc. as it adds extra functions. I want it to be as simple and short as possible.
EDIT:
- Yes, it is a path.
- I do not know the length of the path.
- As mentioned, I do not want to use splits.