First let me post you some example strings:
string_position = ("\"%s\";\"%s\";\"%s\";\"\";\"%s\"\r\n\"%s\";\"%s\";\"%s\";\"%s - %s\";\"%s\";\"%.0f\";\"FR\";\"%.2f\";\"%.2f\";\"%.2f\";\"%s\";\"%s\";\"%s\";\"%s\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"B\"\r\n",POSNR_NR_ID,POSNR_NR_ID,POSNR,POSNR_NR_ID,ARTNR_NR_ID,POSNR_NR_ID,CP90NAME,TEXT1,TEXT2,ARTNR_NR_ID,CNT,WIDTH,HEIGHT,DEPTH,INFO1,INFO2,INFO3,INFO4)
string_position = ("STK_PD_BEZ|%s|STK_ID|%s|STK_EBENE|0|ID|%s\r\nSTK_ID|%s|ORDERPOS|%s|STK_EBENE|1|STK_PD_BEZ|%s|STK_FLAENGE|%.2f|STK_FBREITE|%.2f|STK_FDICKE|%.2f|ID|%s|PARENTID|%s\r\n",POSNR,ORDERID,POSNR_NR_ID,ORDERID,POSSTR,CP90NAME,WIDTH,DEPTH,HEIGHT,ARTNR_NR_ID,POSNR_NR_ID)
So I want to parse those strings, but I don’t know how I could start. As I result I want to have two arrays for each string, for example (string 2):
array_a[0] = STK_PD_BEZ|%s;
array_b[0] = POSNR;
array_a[1] = STK_ID|%s;
array_b[1] = ORDERID;
etc…
I hope you understand my problem. I have to find the complementary “variable” to each %s. So the algorithm has to work with any string that looks like the ones I’ve posted.
Thank you for any help.
Just quick implementation, hope it will be useful. I don’t go with regex for this particualr task. I think simple parser will be enough here.
Output:
Output2:
UPDATE: