# Solution
importrematch=lambdadoc1,doc2:re.match(re.sub('X+','.*?',doc1),doc2)isnotNone# Test cases
cases=[("TOP SECRET:\nThe missile launch code for Sunday XXXXXXXXXX is:\nXXXXXXXXXXXXXXXXX","TOP SECRET:\nThe missile launch code for Sunday 5th August is:\n7-ZERO-8X-ALPHA-1"),("The name of the mole is Professor XXXXX","The name of the mole is Professor Dinglemouse"),("XXXXXXXX XXXXXXX XXXXXXXXXXXXXXXXXXX\nXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXX XXXXXXXXXXXXX XXXXX","Area-51. Medical Report. 23/Oct/1969\nE.T. subject 4 was given an asprin after reporting sick for duty today")]forcaseincases:print(f"doc1: {re.sub('X+','*',case[0])}\ndoc2: {case[1]}\nDoc's match: {match(*case)}")
Python 3, using regex'es:
Try it online!