I have a string which is basically a file path of an .mp4 file.
I want to test if the file path is matching one of the following patterns:
/*.mp4 (nothing before the slash, anything after)
*/*.mp4 (anything before and after the slash)
[!A]*.mp4 (anything before the extension, **except** for the character 'A')
What would be the best way to achieve this? Thanks!
EDIT:
I'm not looking to test if the file ends with .mp4, i'm looking to test if it ends with it and matches each of those 3 scenarios separately.
I tried using the 'endswith' but it's too general and can't "get specific" like what i'm looking for in my examples.
Here they are:
string.endswith('.mp4') and string.startswith('/')
string.endswith('.mp4') and "/" in string
string.endswith('.mp4') and "A" not in string
Or, look at using fnmatch
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With