The client passed me a parameter str = "${param0},${param1}"
.
I want to replace ${param0} ${param1}
with the value I queried from the database.
such as
//str = "${param0},${param1}"
//str = "${param0},${param1}, ${param2}"
//...
public String format(String str) {
String param0 = repository.query0();
//expect
str = "param0,${param1}";
String param1 = repository.query1();
//expect
str = "param0,param1,${param2}";
return str;
}
I know that java.lang.String#replace
can solve the problem. But the parameter str
is indefinite. It could also be str = "${param0}, ${param1}, ${param2}"
or more. Is there any way to satisfy my request?