fork download
  1. import re
  2.  
  3.  
  4. x = re.compile(r'(.*?)(?:\s+\(unwanted static pattern\))?$')
  5. for s in ['This will be captured (unwanted static pattern)',
  6. 'This wil also be captured']:
  7. m = x.search(s)
  8. if m:
  9. print(m.group(1))
Success #stdin #stdout 0.02s 27744KB
stdin
Standard input is empty
stdout
This will be captured
This wil also be captured