This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I'm looking for approaches and solutions to element substitution into a string.
For example a string with elements to be will look like.
Dear ${first_name} ${last_name},
Welcome to our Game Club. We will contact you via you email ${email}.
Where I need to substitute values for the elements that are formated as ${element_name}. So in the example above the elements to be substituted are: ${first_name} ${last_name} ${email}
If you're using Java 1.5, then String has a new method, replace(CharSequence target, CharSequence replacement).
But how exactly you might implement this depends on the bigger picture.
For example, if you have each member's information stored as instances of a small class called Member, and Member instances are all stored in some sort of collection like an ArrayList, then you could iterate through the List, and generate custom Strings for each Member. Under this model, the fragment might look something like this...
[ December 01, 2004: Message edited by: marc weber ]
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.