fork download
  1. import re
  2. line ="JnJ LLC Invoice# SMT/778"
  3. pattern = re.compile('invoice#\s+([A-Za-z]{3}/\d{1,5})', re.I)
  4. print( re.findall(pattern, line) )
  5. # get the first match
  6. m = pattern.search(line)
  7. if m:
  8. print(m.group(1))
Success #stdin #stdout 0.01s 7224KB
stdin
Standard input is empty
stdout
['SMT/778']
SMT/778