Code function serial

Hi all, I need help with the following code:

Since the Arduino number 1 sent the following data:
12 @ 34% 56/78) 91 & 23. At the end of the sentence ended with a point, and I separate the variables with rare characters:

In the Arduino number 2, where these data are received, it is where I have the problem:
With java, would put the following code, but do not quite see Arduino works:

void serialEvent (Serial port) {
valor = port.readStringUntil('.');

valor = valor.substring(0, valor.length() - 1);

index1 = valor.indexOf('@');
index2 = valor.indexOf('%');
index3 = valor.indexOf('/');
index4 = valor.indexOf(')');
index5 = valor.indexOf('&');

p1boton = valor.substring(index1+1, index2);
ypos1 = valor.substring(index2+1, index3);
p1ypos = Integer.parseInt(ypos1);

p2boton = valor.substring(index4+1, index5);
ypos2 = valor.substring(index5+1, valor.length());
p2ypos = Integer.parseInt(ypos2);

Which it makes this part of the program is to collect all data and separate them, but in C ++ (in Arduino code), I don't know which is the code.
The would greatly appreciate a little help !!!
Thanks!

Maybe have a look at Serial.parseInt(), you can seperate the values by commas (or some other character), each time you use serial.parseInt() it will grab the next valid int value up to the next comma and then dispose of the comma.

Have a look at the examples in serial input basics. They read in all the data and you can then parse it. There is a parse example.

I don't like Serial.parseInt() because it blocks until it gets a value.

...R

valor = valor.substring(0, valor.length() - 1);

Why? Making a substring that is the same as the original String is useless.

Which it makes this part of the program is to collect all data and separate them, but in C ++ (in Arduino code), I don't know which is the code.

What have you tried? The method names are the same.