fork download
  1. import re
  2.  
  3. regex = r"\(([^()/]+(?:/[^()/]+)*)\)"
  4.  
  5. test_str = "stuff (word1/Word2/w0rd3) stuff, stuff (word4/word5) stuff stuff (word6) stuff (word7/word8/word9) stuff stuff, (w0rd10/word11) stuff stuff (word12) stuff (Word13/w0rd14/word15) stuff-stuff stuff (word16/word17)."
  6.  
  7. res = list(map(lambda x: x.split('/'), re.findall(regex, test_str)))
  8. print(res)
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
[['word1', 'Word2', 'w0rd3'], ['word4', 'word5'], ['word6'], ['word7', 'word8', 'word9'], ['w0rd10', 'word11'], ['word12'], ['Word13', 'w0rd14', 'word15'], ['word16', 'word17']]