I have a dataframe of which this is a part.
CodeID Codes
0 'code1' '[code1(a,b,c)][code2(c,d,e)][code3(e,f,g)]' ...
1 'code2' '[code1(a,b,c)][code2(c,d,e)][code3(e,f,g)]' ...
2 'code3' '[code1(a,b,c)][code2(c,d,e)][code3(e,f,g)]' ...
...
What I'm trying to do is extract the part of the string in column Codes that matches the pattern r"\[<code in CodeID column>[^][]*\]"
Something like:
df['Code'] = df['Codes'].str.find(r"\[<code in CodeID column>[^][]*\]")
This recent question seems to imply it's not possible in a vectorised way but it's not exactly the same situation.
r"\[<code in CodeID column>[^][]*\]"