fork(19) download
  1. line = ' Cmaj7 F#m C7 '
  2. import re
  3. notes = "[CDEFGAB]";
  4. accidentals = "(?:#|##|b|bb)?";
  5. chords = "(?:maj|min|m|sus|aug|dim)?";
  6. additions = "[0-9]?"
  7. print re.findall(notes + accidentals + chords + additions, line)
  8.  
Success #stdin #stdout 0.08s 10864KB
stdin
Standard input is empty
stdout
['Cmaj7', 'F#m', 'C7']