fork download
  1. import re
  2.  
  3. rx = re.compile(r'\b\d+x\d+(?:[-_]e?\d+)*')
  4.  
  5. texts = ['alphanumeric 1x01-e02-03-04',
  6. 'hello-char 2x01-02-03_04',
  7. 'hello 3x02 char 2x01-02-03_04']
  8.  
  9. for text in texts:
  10. print([re.split(r'[-_]e?', x) for x in rx.findall(text)])
Success #stdin #stdout 0.02s 9372KB
stdin
Standard input is empty
stdout
[['1x01', '02', '03', '04']]
[['2x01', '02', '03', '04']]
[['3x02'], ['2x01', '02', '03', '04']]