I am struggling to come up with a universal regexp that will remove/isolate all leading/trailing garbage from a multi-line string, leaving only the JSON. Without opening up a temporary buffer to re-search-forward/backward for the first and last wavy brackets, how can I programmatically remove everything before the first { and everything after the last }?
CAVEAT: Sometimes, there may not necessarily be any leading/trailing garbage, but there often will be.
BEFORE
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. [Donec hendrerit
tempor tellus.]
Donec pretium posuere tellus. Proin quam nisl, tincidunt et,
mattis eget, convallis nec, purus. {Cum sociis natoque [penatibus et] {magnis
dis} parturient montes, {nascetur ridiculus} mus.} Nulla posuere. Donec vitae
dolor."
AFTER
"{Cum sociis natoque [penatibus et] {magnis
dis} parturient montes, {nascetur ridiculus} mus.}"
{" and "anything after last}" then I think you've complicated this question by talking about JSON at all.curland the JSON of interest is preceded by% Total % Received % Xferd ... 0 --:--:-- ...In other cases, data is retreived usingurl-retrieve-synchronouslyand the JSON data is preceded byHTTP/1.1 200 \nDate: Tue, 04 Jan 2022 21:02:32 GMT\nContent-Type: application/json...As this project moves forward, there might also be the need to remove nonessential information tailing the JSON of interest.-soption available withcurlseems to do the trick. This will also avoid the problem of intermittent download/status details fromcurlbeing interdispersed within the body of lengthy responses.