fork download
  1. import re
  2.  
  3. text = "a/NNP b/NNG c/NP d/NNP e/PNG"
  4. words = re.compile(r'\w+/(?:NNP|NNG)\b')
  5. print(re.findall(words,text))
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
['a/NNP', 'b/NNG', 'd/NNP']