I work with JSON lists which can look somewhat like the following:
[
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$unauthenticated",
"permission": "DENY"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW"
}
]
What would be the proper way to write a regex which correctly extracts only the list item which contains the word $everyone? I need to extract the entire object, so the correct result should be:
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
}
I have tried something like \{(?s).*everyone(?s).*\}, but this will match the first and last opening and closing curly bracket in the list, with everything in between.
.*?instead of.*?.*?instead of.*.\{(?s).*?everyone(?s).*?\}almost works, in the sense that it stops the search at the first}encountered aftereveryoneis found. Now I only need it to also start at the first{before that.\{[^}]*?everyone[^}]*\}