Regex match everything up until sequence of characters -
i trying extract part of json message failing write correct regex.
biggest problem application writing (impala - big data query engine) contains bug preventing non-greedy operations using ?
, therefore need different solution.
example
{"postcode":"abcdef","forename":"james","id":"{12}","surname":"townsend"}, {"postcode":"hijklm","forename":"toby","id":"{34}","surname":"taylor"}, {"surname":"reilly","postcode":"nopqrs","forename":"mike","id":"{56}"}
the data in format in 1 string (no line breaks) inside each "section" the data can in order.
i need use regex end part of message forename "toby"
{"postcode":"hijklm","forename":"toby","id":"{34}","surname":"taylor"}
currently have
{[^{]*"forename":"toby"[^}]*}
however doesn't work work, need match {"
, "}
start , end.
can please offer advice on how this?
thanks
escape leading/trailing curly brackets:
\{[^{]*"forename":"toby"([^}]|\}(?="))*\}(?!")
see live demo.
Comments
Post a Comment