'Group(s) around a word

I request your help. I've been trying to get a specific regex to work but I can't get it to do what I need.

The regex will group anything around [test], not itself. For example,

Input: [{1,/;k1`\n\t[test]|}[{3\n\t,/[test;k1`\n\t[test][test]|}[{9\n\t,/;s2`\t\n{...}
Output: 
        Group 1: [{1,/;k1`\n\t
        Group 2: |}[{3\n\t,/[test;k1`\n\t
        Group 3: 
        Group 4: |}[{9\n\t,/;s2`\t\n
        Group n: {...}

Also works without it

Input: [{1,/;k1[tes]`\n\t
Output: 
       Group 1: [{1,/;k1[tes]`\n\t

*Note: regex uses Expression Flags: /ig



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source