fork download
  1. import re
  2. text = '{\\"event\\":{\\"header\\":{\\"transactions\\":{\\"localTransactions\\":{\\"id\\":\\"11111111-239e-4f86-9f5a-111111111111\\",\\"sourceApplication\\":{\\"name\\":\\"worker\\",\\"host\\":\\"worker-67bcdfc6bb\\"},\\"createdAt\\":\\"2021-04-08T14:05:03.571Z\\",\\"websocketId\\":\\"abc=\\"},\\"localTransaction\\":[]},\\"user\\":null,\\"interceptorId\\":null},\\"payload\\":{\\"operation\\":{\\"operationCode\\":\\"500\\",\\"applicationErrorCode\\":\\"202\\",\\"operationMessage\\":\\"Exception\\",\\"status\\":\\"failure\\",\\"reason\\":\\"Failure - Failed to ggg.\\"},\\"response\\":{\\"operation\\":{\\"operationCode\\":\\"500\\",\\"applicationErrorCode\\":\\"CP0202\\",\\"operationMessage\\":\\"Exceptio. We are working on it and will in [TRUNCATED]'
  3. regex_pattern = r'localTransactions\\":{\\"id\\":\\"(.*?)\\",\\"sourceApplication'
  4. regex_result = re.search(regex_pattern, text)
  5. if regex_result:
  6. print("We have a match!", regex_result.group(1), sep="\n")
  7. else:
  8. print("No match")
Success #stdin #stdout 0.03s 9388KB
stdin
Standard input is empty
stdout
We have a match!
11111111-239e-4f86-9f5a-111111111111