I need to match the contents of the list with the given template and form another list that will contain everything except matches. Meaning, I'm trying to make a list of exceptions.
Now with one pattern matching, it's easy. But for more than that, it becomes complicated.
Let's look at an example:
Lmain=[arc123, arc234,xyz111,xyz222,ppp999,ppp888]
for count in range(len[Lmain]):
if Pattern matches Lmain[i]:
Pass
else:result.append(Lmain[i])
Now let's say pattern = arc, my result will be
result = [xyz111,xyz222,ppp999,ppp888]
This is just the logic where I will use the regex to match.
Now, if we have 2 patterns, then using the above logic in a loop:
Pattern=['arc','xyz']
for pat in Pattern:
if pat matches Lmain[i]:
Pass
else:result.append(Lmain[i])
This will give us the wrong result.
result = [xyz111,xyz222,ppp999,ppp888,arc123,arc234,ppp999,ppp888]
So you can see that the logic just doesn't work.
My plan:
First, we find the exception list for the first template, which will give us the result:
result = [xyz111,xyz222,ppp999,ppp888]
For the second template, we need to look at the result above.
if Pattern matches Result[i]:
Pass
else:result_final.append(Result[i])
, Recursion . , ?
, . .
- , , , .