I need to use or create a comparison function in Python, perhaps it already exists a way of doing this?
I need to compare a string with a value in a list, and I need to make a match even if it's a couple of characters off. I'll make an example so you can see what I mean.
Example 1:
Value in list : Name: This is the title
Value in search : Name This is the title
Example 2:
Value in list : Name and shortening m.m.
Value in search : Name and shortening m.m
As you can see the values I want to compare and need to match are very similar. The values in the search are folder names so they are a bit different because they contain illegal characters.
Maybe the easiest way to accomplish this is to remove none allowed characters from the string before making the comparison \/:*?"<>|
and any trailing points.
Any tips on what's the most efficient way of comparing the strings and get a match is?
Edit: Is this an ugly way of doing it?
def Cleanup(Str):
Illegal = ['\\','/',':','*','?','"','<','>','|']
return ''.join([char for char in Str if char not in Illegal]).rstrip('.')