// 直接使用hutool工具类即可
// format("this is {} for {}", "a", "b") =》 this is a for b
StrFormatter.formatWith("aa ${}", "${}", "b")
// format("this is {} for {}", "{}", "a", "b") =》 this is a for b
StrFormatter.formatWith("aa {}", "b")
// format 格式化文本,使用 {varName} 占位<br>
// map = {a: "aValue", b: "bValue"} format("{a} and {b}", map) ---=》 aValue and bValue
Java 模板变量替换——字符串替换器{}、${}、${}map
最新推荐文章于 2024-07-08 18:25:59 发布