Reputation: 1365
I'm looking for the way of comparing two strings and being able to get back, as separate strings:
Example:
A = "123 ABC"
B = "135 AZ"
thingamajigger(A, B) # would give all these:
intersect = "13 A" # (includes space)
exclusion = "2BCZ5"
a_minus_b = "2BC"
b_minus_a = "5Z"
a_minus_b
is quite simple... but if there's one of those fancy one-liner ways to pull it off, then I'm open.
for i in B:
A = A.replace(i, "")
It's a bit like boolean operations on strings.
Upvotes: 14
Views: 19645