直接上问题
String s="你好_,今天是_年_月_日.";
String name="某人";
String year="2012";
String month="03";
String day="16";
通过字符串替换
s.replace(oldChar, newChar)
我希望得到的结果是
你好某人,今天是2012年03月16日.
请问怎么做?
------解决方案--------------------
- Java code
String name="某人"; String year="2012"; String month="03"; String day="16"; System.out.println(s.replaceFirst("_", name).replaceFirst("_", year).replaceFirst("_", month).replaceFirst("_", day));