I have a list of data that includes both command strings as well as the alphabet, upper and lowercase, totaling to 512+ (including sub-lists) strings. I want to parse the input data, but i cant think of any way to do it properly other than starting from the largest possible command size and cutting it down until i find a command that is the same as the string and then output the location of the command, but that takes forever. any other way i can think of will cause overlapping. im doing this in python
say:
L = ['a', 'b',['aa','bb','cc'], 'c']
for ‘bb’ the output would be ‘0201’ and ‘c’ would be ’03’
so how should i do this?
It sounds like you’re searching through the list for every substring. How about you built a dict to lookup the keys. Of cause you still have to start searching at the longest subkey.
You could then lookup substrings with:
But if the key length is not just 1 or 2, it might also make sense to group the items into separate dicts where each key has the same length.