我想在字符串的每个“ from”前面添加“ count(*)”。
给出:Select thing1, thing2 from table;
输出:Select thing1, thing2, count (*) from table;
我尝试了这个,但是没有用:
String a = “ Select thing1, thing2 from table;”
String[] b = “form”.split(“\\s”)
For(string string: b){
If(a.contains(form)
}
答案 0 :(得分:1)
尝试一下:
int idx = a.indexOf("from");
System.out.println(a.substring(0, idx-1) + ", count(*) " + a.substring(idx));
输出:
Select thing1, thing2, count(*) from table;