import json, re print(json.dumps( { "cameraId": "D72154040", "endTime": 1577267418999, "image": "http://evcloudsvc.ilabservice.cloud/video/D72154040/1550143347000-1577267418999/firstFrame.jpg", "length": 260, "startTime": 1550143347000, "video": "http://evcloudsvc.ilabservice.cloud/video/D72154040/1550143347000-1577267418999/1550143347000-1577267418999.mp4" })) rawStr = "edet found human 0.838 x: 645, y: 353, w: 278, h: 348; written image: /apps/app/D72154040/1550143347000-wzGsNR//detect_1580371688.jpg; time: 3" m = re.match(r".*? found (\w+) ([\d\.]+) .*? image: .*?/([_\w\d]+.jpg).*?time: ([\d\.]+)", rawStr) if m: print("matched", m.group(1)) else: print("no match")