I want to split the string into separate list based on the pattern. Let say I have the string look like this
string = '1.e4 d6 2.d4 Nf6 3.Nc3 g6 4.Nf3 Bg7 5.Be2 Nbd7 6.O-O O-O 7.e5 dxe5 8.dxe5 Ng4 9.e6 Nde5 10.Qxd8 1-1 1.c2 d6 2.d4 Nf6 3.Nc3 g6 4.Nf3 Bg7 5.Be2 Nbd7 6.O-O O-O 7.e5 dxe5 8.dxe5 Ng4 9.e6 Nde5 10.Qxd8 Rxd8 11.Nxe5 Nxe5 1-0 1.b5 d6 2.d4 Nf6 3.Nc3 g6 4.Nf3 Bg7 5.Be2 Nbd7 6.O-O O-O 7.e5 dxe5 8.dxe5 Ng4 9.e6 Nde5 10.Qxd8 Rxd8 11.Nxe5 Nxe5 12.Nb5 1/2-1/2'
The pattern should recognize the 1. as the start, and end before another 1.
[1.e4 d6 2.d4 Nf6 3.Nc3 g6 4.Nf3 Bg7 5.Be2 Nbd7 6.O-O O-O 7.e5 dxe5 8.dxe5 Ng4 9.e6 Nde5 10.Qxd8 1-1]
[1.c2 d6 2.d4 Nf6 3.Nc3 g6 4.Nf3 Bg7 5.Be2 Nbd7 6.O-O O-O 7.e5 dxe5 8.dxe5 Ng4 9.e6 Nde5 10.Qxd8 Rxd8 11.Nxe5 Nxe5 1-0]
[1.b5 d6 2.d4 Nf6 3.Nc3 g6 4.Nf3 Bg7 5.Be2 Nbd7 6.O-O O-O 7.e5 dxe5 8.dxe5 Ng4 9.e6 Nde5 10.Qxd8 Rxd8 11.Nxe5 Nxe5 12.Nb5 1/2-1/2]
I do something like this
lists=[]
reg = '^\\1\\.'
for i in string :
re.match(reg, i)
lists.extend[i]
string.split(' 1.')['1.e4 d6 2.d4 Nf6 3.Nc3 g6 4.Nf3 Bg7 5.Be2 Nbd7 6.O-O O-O 7.e5 dxe5 8.dxe5 Ng4 9.e6 Nde5 10.Qxd8 1-1', 'c2 d6 2.d4 Nf6 3.Nc3 g6 4.Nf3 Bg7 5.Be2 Nbd7 6.O-O O-O 7.e5 dxe5 8.dxe5 Ng4 9.e6 Nde5 10.Qxd8 Rxd8 11.Nxe5 Nxe5 1-0', 'b5 d6 2.d4 Nf6 3.Nc3 g6 4.Nf3 Bg7 5.Be2 Nbd7 6.O-O O-O 7.e5 dxe5 8.dxe5 Ng4 9.e6 Nde5 10.Qxd8 Rxd8 11.Nxe5 Nxe5 12.Nb5 1/2-1/2']this is the result if i run the code. maybe because it is splitting by 1. and everytime it find 1. it will take the next value