fork download
  1. # your code goes here
  2. import re
  3. import json
  4.  
  5. text ={"id": 5931,"iid": 4145,"project_id": 57,"title": "Change: SELAP-3333, SFCAP-3139","state": "opened SELAP-3333","created_at": "2020-09-24T15:04:05.728+02:00","updated_at": "2020-09-24T15:04:09.903+02:00","author": {"username": "veeti"}}
  6.  
  7. data = json.dumps(text)
  8.  
  9. change_id_regex = re.compile(r"""([A-Z][A-Z0-9]+-[0-9]+)""")
  10.  
  11. #replaced_json = re.sub(change_id_regex, "test", data["title"])
  12. replaced_json = re.sub(change_id_regex, "test", data)
  13.  
  14. print( replaced_json )# your code goes here
Success #stdin #stdout 0.02s 9608KB
stdin
Standard input is empty
stdout
{"id": 5931, "iid": 4145, "project_id": 57, "title": "Change: test, test", "state": "opened test", "created_at": "2020-09-24T15:04:05.728+02:00", "updated_at": "2020-09-24T15:04:09.903+02:00", "author": {"username": "veeti"}}