fork download
  1. import re
  2.  
  3. regex = r"[^\s@]+@(?:[^][\s@]+|\[[^][]*])"
  4. s = "k1@v1 k2@[v1 v2 v3] k3@v1"
  5.  
  6. matches = re.findall(regex, s)
  7. print(matches)
Success #stdin #stdout 0.02s 9624KB
stdin
Standard input is empty
stdout
['k1@v1', 'k2@[v1 v2 v3]', 'k3@v1']