I am trying to see if a string contains certain text and if so do something, i have been using python's in
operator, but i realized its too strict basically i have the following code
Usually this would return True
dynamic = "v23434"
filename = "v23434.jpg"
if dynamic in filename: return True
however, if i have
dynamic = "v23434-"
filename = "v23434.jpg"
then it returns False, due to the dash at the end of dynamic
, so my question is, is there a way to check if the string filename has the string dynamic
, but in a way that it doesn't have to be a perfect match, a few characters is enough.
EDIT
By a few characters, i mean a substring made up of the first 3 characters in dynamic, so if i have
dynamic = "v23434-"
filename = "testingv23434.jpg"
then it should match, because the substring "v23"
is found inside filename