The values that you added to the String are now part of the String, so there is no way to "reverse" it.
Otherwise, if you know that the given string is going to follow a certain pattern such like
"a number " + digits here + ", a name " + a word here
I would suggest you to use regex:
This expression:
/number ([0-9]*)/
will return the number as group 1.
And this one:
/, a name (\w*)/
will return the name again as group 1.
You can merge both regex in one expression such like:
/a number ([0-9]*), a name (\w*)/
Which will return the number as group 1 and the name as group 2.
So this code should do the trick:
Matcher m = p.matcher("a number ([0-9]*), a name (\w*)");
if (m.find()) {
System.out.println(m.group(0)); // number
System.out.println(m.group(1)); // name
}
Also, if you want to approach the posibility of having surnames, you should change \w
properly.
If you need them on an array refer to this post.