You can just use java.util.regex.Pattern and java.util.regex.Matcher for this. Create a
Pattern for the place holders (
&.+?; - the .+? is a non-greedy catch-all), look for all occurrences (as long as the Matcher's find() method returns true), investigate the match and if it's one you're looking for, replace it. You can use Matcher's appendReplacement and appendTail to finalize your String. In a bit of pseudo code: