String Inf = "商品号:[1234567890]金额:[3333.00]联单号:[87373737]"有办法实现在商品号、金额、联单号前空两个格或者另排一行 商品号:[1234567890] 金额:[3333.00] 联单号:[87373737]"
或者
商品号:[1234567890]
金额:[3333.00]
联单号:[87373737]"
或者
商品号:[1234567890]
金额:[3333.00]
联单号:[87373737]"
String Inf = "商品号:[1234567890]"+" "+"金额:[3333.00]"+" "+" 联单号:[87373737]";
String Inf2 = "商品号:[1234567890]"+"\n"+"金额:[3333.00]"+"\n"+"联单号:[87373737]";
public static void main(String[] args) {
String Inf = "商品号:[1234567890]金额:[3333.00]联单号:[87373737]".replace("]", "]\t");
System.out.print(Inf);
System.out.println();
String inf = "商品号:[1234567890]金额:[3333.00]联单号:[87373737]".replace("]", "]\n");
System.out.print(inf);
}
}
String sss = "商品号:[1234567890]金额:[3333.00]联单号:[87373737]";
Pattern p = Pattern.compile(".+?(?>\\])");
Matcher m = p.matcher(sss);
while(m.find()) {
System.out.println(m.group());
}