Reputation: 125
I am trying to search for a string "SAMPLEX_FIND", where abphabet in place of "X" might vary. For example- "ABCSAMPLEA_FINDER", "asrSAMPLEB_FINDer" etc.
Upvotes: 0
Views: 21
Reputation: 2863
You can use regex for that:
import re
example = "ABCSAMPLEA_FINDER"
print(re.findall(r".*SAMPLE._FIND.*", example)[0])
Note that if the function couldn't find the pattern, the result would be an empty list and the index won't work
Upvotes: 1