fork download
  1. import re
  2.  
  3. def rm_strings_from_data(data):
  4. regex = re.compile(r'(\w+?)=(".*?")')
  5. matches = regex.finditer(data)
  6. strings = []
  7. list_data = []
  8. for matchNum, match in enumerate(matches):
  9. matchNum = matchNum + 1
  10. strings.append(match.group(2))
  11. list_data.append((match.group(1) + '={' + str(matchNum) + '} '))
  12.  
  13. print(strings, '[' + ''.join(list_data) + ']', sep='\n\n')
  14.  
  15. if __name__ == '__main__':
  16. rm_strings_from_data('[hi="hello!" thing="a thing!" other="other thing"]')
Success #stdin #stdout 0.04s 9752KB
stdin
Standard input is empty
stdout
['"hello!"', '"a thing!"', '"other thing"']

[hi={1} thing={2} other={3} ]