fork(2) download
  1. # coding=utf8
  2. # the above tag defines encoding for this document and is for Python 2.x compatibility
  3.  
  4. import re
  5.  
  6. r = re.compile(r"(?<=\()'([^']*)'(?=.*?\('([^']*)')")
  7. s = "[('APPLE', 'NN'), ('BANANA', 'NN'), ('GRAPE', 'NN'), ('PEAR', 'NN')]"
  8.  
  9. for m in re.finditer(r, s):
  10. print m.group(1) + ' ' + m.group(2)
Success #stdin #stdout 0.02s 6816KB
stdin
Standard input is empty
stdout
APPLE BANANA
BANANA GRAPE
GRAPE PEAR