Я уже делал это на Java, но не могу вспомнить, как именно.
Вы создаете строку:
String foo = "She %s sea shells by the seashore.";
Затем вы можете написать в строку слово "продает ".
Что вы используете для этого?
String myString = "sells"; String foo = String.format("She %s sea shells by the seashore.", myString);
Вы ищете Formatter класс или String.format удобный метод :
Formatter
String.format
String.format(foo, "sells");
string.Format
Object a[] = { "Real's HowTo", "http://www.any.com" , java.util.Calendar.getInstance()}; String s = String.format("Welcome %1$s at %2$s ( %3$tY %3$tm %3$te )", a); System.out.println(s); // output : Welcome Real's HowTo at http://www.any.com (2010 06 26)
Для этого вы можете использовать функцию String.Format.
String.Format
Прямо из источника (и моих закладок) ...
StringBuilder sb = new StringBuilder(); // Send all output to the Appendable object sb Formatter formatter = new Formatter(sb, Locale.US); // Explicit argument indices may be used to re-order output. formatter.format("%4$2s %3$2s %2$2s %1$2s", "a", "b", "c", "d");
ОБНОВЛЕНИЕ: Извините, я хотел добавить ссылку: http://download.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html