J
Jed Ozone
New to Regex and I'm having a hard time figuring this one out.
I need a regular expression what will based on balanced square brackets.
For example:
[$AA[123]], [BB[bb],CC], [a[b[c]]]
I'm trying to write a reg ex that will parse the above into 3 pieces:
1) [$AA[123]] (or $AA[123] would be fine)
2) [BB[bb],CC]
3) [a[b[c]]]
Basically, any time the square brackets balance, I want to be able to pluck
out that value.
I wrote: (?<column>\[([^\[\]]*(\[.*\])*)*\])
Basically, look for a [, then repeatly take either a non-"[" and non-"]"
character or find an internal set of [...] and take everything between them;
until you hit a ]. It's the later part that doesn't work as I can't seem to
figure out how to get the brackets to balance properly. Is this just
something regular expression are not meant to do? Thanks for any help.
I need a regular expression what will based on balanced square brackets.
For example:
[$AA[123]], [BB[bb],CC], [a[b[c]]]
I'm trying to write a reg ex that will parse the above into 3 pieces:
1) [$AA[123]] (or $AA[123] would be fine)
2) [BB[bb],CC]
3) [a[b[c]]]
Basically, any time the square brackets balance, I want to be able to pluck
out that value.
I wrote: (?<column>\[([^\[\]]*(\[.*\])*)*\])
Basically, look for a [, then repeatly take either a non-"[" and non-"]"
character or find an internal set of [...] and take everything between them;
until you hit a ]. It's the later part that doesn't work as I can't seem to
figure out how to get the brackets to balance properly. Is this just
something regular expression are not meant to do? Thanks for any help.