This seems to work OK for me
void setup()
{
Serial.begin(115200);
char msg[] = "# # 12 # 1 # # 13 # 0 # # 14 # 0";
char *part;
Serial.println(msg);
part = strtok (msg,"#");
while (part != NULL)
{
Serial.println(part);
part = strtok (NULL, "#");
}
}
void loop()
{
}
The string (note lowercase s) variable can come from anywhere and as long as its format is consistent strok() can be used to split it. The program prints the parts as they are split off but it could equally well be used to ascertain the pin numbers and the required output.