fork download
  1. import re
  2. regex = r"'lo'(?:,\s*)?|[][']"
  3. test_str = "['lo', 'ens4', 'tun0', 'tun1']"
  4. result = re.sub(regex, "", test_str)
  5.  
  6. if result:
  7. print (result)
  8.  
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
ens4, tun0, tun1