The question I have is regarding the identification of a series of string in python. Let me explain what I am trying to do:
A string such as tom and jerry could also be written as in lowercase
- tom n jerry
- tom_jerry
- tom & jerry
- tom and jerry
and so on and so forth. As you can see there in the minimal example, there were 4 possible ways where even if I created a dictionary with these 3 ways, i will miss out on a string containing tom _ jerry. What can I do to recognize tom and jerry, creating many rules seems very inefficient. Is there a more efficient way to do this ?
s.startswith("tom") and s.endswith("jerry")to test a given stringsand it'd return true for all of the examples. But it would also return true for really huge strings that you might not want to accept, and it would return false on minor mispellings of eithertomorjerry, which you also might not want.s.startswith("tom") and s.endswith("jerry") and len(s) < 15