fork download
  1. import re
  2. s = ' LICENSE INVALID\n Your license does not include module AMS version 2020.103 on this machine.\n Module AMS\n LICENSE INVALID\n Module AMS version2020.103\n Your license does not include module AMS version 2020.103 on this machine.\n Module AMS\n Module AMS version2020.103\nLICENSE INVALID\nLICENSE INVALID'
  3. p=re.compile(r'^(?!.*\b(?:LICENSE INVALID|license does not include)\b)(?=.*(?<!\d)2020\.103(?!\d))(?=.*\bNORMAL TERMINATION\b).*', re.S)
  4. print(p.search(s)) # NO MATCH, there is "LICENSE INVALID" and even "license does not include", there is no expected "NORMAL TERMINATION", although there is "2020.103"
  5. print(p.search('NORMAL TERMINATION\nBlah-blah\n2020.103 code')) # MATCH, there are no "LICENSE INVALID" and "license does not include", there is "NORMAL TERMINATION" and "2020.103"
  6. print(p.search('NORMAL TERMINATION\nBlah-blah\n2020.1030 code')) # NO MATCH, same as above but "2020.1030" is not "2020.103"
Success #stdin #stdout 0.03s 9480KB
stdin
Standard input is empty
stdout
None
<re.Match object; span=(0, 42), match='NORMAL TERMINATION\nBlah-blah\n2020.103 code'>
None