This method invocation
txt.match(/\[.*\]/g)
works exactly as intended - it returns an array of matches
[anytext1],[anytext2],[anytext3]
I don't need the brackets, so out of curiosity I tried this tweak
txt.match(/\[.*(?=\])/g)
which - somewhat to my surprise I must admit - does exactly what I was hoping it would do and returns
[anytext1,[anytext2,[anytext3
(IOW the closing bracket is not included in the match).
Emboldened by that success I tried this further tweak
txt.match(/(?:\[).*(?=\])/g)
but was disappointed; that also returns
[anytext1,[anytext2,[anytext3
(IOW the opening bracket is still included in the match).
The asymmetry of the (? operators in this context appears to be a glitch; either that or the (?: doesn't do what I think it does.