I have a multiline string variable which includes multiline of system log like below, and I would like to extract the JSON part only
System 123456
Logs start 2021-07-03 12:00:00
<event> {log_in_json}
<event> {log_in_json}
I using find to search over the string variable but this only allow me to get the first occurrence. Anyone could advise?
start = var.find(<event>)
end = var.find("}}")
extracted_line = var[start:end+len("}}")]
json_str = extracted_line.lstrip(<event>)
print(json_str)