Here is a template that can suit your needs:
^\[!((?<n>\w+='\[!)|(?<inner-n>!]')|\w+='(?!\[!)[^']*'| )*!](?!(n))$
It will provide the innermost item for each item in order. To explain what I mean, given the code:
[!a='test' c='[!x='blah'!]' b='[!a='[!y='innermost'!]' b='innervalue'!]' !]
It will give the following matches (in the capture collection for the "inner" group):
x='blag' y='innermost' a='[!y='innermost'!]' b='innervalue'
So, for each element x=y in [! .. !] [! .. !] he will give coincidences in order from the innermost outward.
If you want the general expression to be captured, you can change it as follows:
^(?<n>\[!)((?<n>\w+='\[!)|(?<inner-n>!]')|\w+='(?!\[!)[^']*'| )*(?<inner-n>!])(?!(n))$
Donation:
x='blag' y='innermost' a='[!y='innermost'!]' b='innervalue' a='test' c='[!x='blag'!]' b='[!a='[!y='innermost'!]' b='innervalue'!]'
And to explain the regex:
^
porges
source share