I need to split this string
(2005)[1]1,2,3,4[2]1(2008)[2]2–;3,4(2009)[3]1,2,3-4(2010)[4]1,2,3-4(2011)[5]1(2012)[5]2,3-4[6]1,2\[\](2014)[6]3-4[7]1-2(2015)[7]3-4[8]1-2(2016)[10]1[8]3-4[9]1-2,3-4(2017)[10]2
As:
1, "1,2,3,4"
2, 1 2
2, 2–;3,4
For the input "(2005)[1]1,2,3,4" I need value in [ ] in capture group 1 and the rest of the string (1,2,3,4) in capture group 2 and repeat for the entire string
I have created this regex string but it is not working as intended
\[(.*?)\](.+?)(?=\[|\(|$)
Please see my regex implementation
The problem is when there is nothing after [] it is capturing (year) which it should not do
\[([^\]\[]*)\]([^\[(]*). Also, you might as well replace.+?with.*?in your pattern.