fork(1) download
  1. import re
  2. text = "there are many people in the world having colorectal cancer (crc) who also have the depression syndrome (ds)"
  3. acrolen=5
  4. rt=[]
  5. acronym_list = ["(crc)", "(ds)"]
  6. for acro in acronym_list:
  7. p = r'(?:\w+\W+){1,%d}%s' %(acrolen, re.escape(acro))
  8. find_words= re.findall(p, text, re.I)
  9. for word in find_words:
  10. rt.append(word)
  11. print rt
Success #stdin #stdout 0s 9024KB
stdin
Standard input is empty
stdout
['the world having colorectal cancer (crc)', 'also have the depression syndrome (ds)']