fork download
  1. import re
  2.  
  3. regex = r"\{'[^']+':\s*\['([^][]+)'\]}"
  4.  
  5. test_str = ("email id\n"
  6. "{'email': ['test@test.com']} {'id': ['123abc_d456_789_fgh']}")
  7.  
  8. subst = "\\1"
  9.  
  10. result = re.sub(regex, subst, test_str, 0)
  11.  
  12. if result:
  13. print (result)
  14.  
  15.  
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
email                                    id
test@test.com           123abc_d456_789_fgh