fork download
  1. import re
  2. text_list = ['Industry / Gemany / PN M564839', 'Industry / France / PN: 575-439', 'Telecom / Gemany / P/N 26-59-29', 'Mobile / France / P/N: 88864839']
  3. regex = r"/ P/?N:? ([\w-]+)"
  4. res = []
  5. for text in text_list:
  6. matches = re.search(regex, text)
  7. if matches:
  8. res.append(matches.group(1))
  9.  
  10. print(res)
  11.  
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
['M564839', '575-439', '26-59-29', '88864839']