fork download
  1. import re
  2. s = "I want to get [samsung](brand) within [1 week](duration) to be happy.";
  3. print(re.split(r'⦅([^⦅⦆]+)⦆', re.sub(r'\[([^][]*)]\(([^()]*)\)', r'⦅\1:\2⦆', s)))
Success #stdin #stdout 0.02s 9792KB
stdin
Standard input is empty
stdout
['I want to get ', 'samsung:brand', ' within ', '1 week:duration', ' to be happy.']