I am getting a String, for ex.: "The user << a1 >> is << a2 >> 50 years old."
And I also have an array with the data that needs to go in the String! For ex. a[0]= "John" ; a[1]= "30"
So, for this example, I would like to replace << a1 >>
with John
and << a2 >>
with 30.
The only thing I was able to find was the following question: How to replace a set of tokens in a Java String?, but to be honest I did not understand anything and wasn't sure if that's what I'm really looking for.
So, is that really what I need to work with? If it is, I'll go read some tutorials.
Thanks in advance.
EDIT: NOTE: I don't have control over the String coming in though. So it will be exactly the way I typed it. All variables are in the form << a0 >>
and the number of variable is unknown (there might even be 10 variables).