I have a CSV in following convention
val1,val2,outerStruct1{valA,valB,innerStruct2{valX, valY},valC},...
The problem is when I try to regex the outerStructure1 I get:
outerStruct1{valA,valB,innerStruct2{valX, valY}
instead:
outerStruct1{valA,valB,innerStruct2{valX, valY},valC}
So apparently it returns on the first }
instead of last (valid) one. My current regex is:
([a-zA-Z0-9]{0,}\\{.*?\\})
How can I expand it to reach the appropriate right brace?
\{.*?\}(?=(?:[^{}]*|\{[^{}]*(?:\{[^{}]*\}[^{}]*)*\})*$)
The general idea is to check that after your match, only balanced curly brackets remain til the end of the string.
However, note that this regex is not recursive and will not handle nesting greater than 2 levels.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.