我有一个由一些字符串数组组成的静态数组
String str = ""; String[] sA = { "ai", "au", "oi" }; String[] sB = { "b", "c", "d" }; String[] sC = { "th", "ng", "sy" };
如何基于这些字符串数组拆分句子,以便在拆分为字符串str后从每个字符串数组中添加不同的标点符号? 例如:
String s = "This ball color is beautiful";
结果如果sA的分裂标点符号是' - ',则sB的分裂标点符号为' _',sC&f 39分拆标点符号为&# 39; =':
str = "=is _all _olor is _e-tiful";
任何帮助将不胜感激!
答案 0 :(得分:0)
你终于分手了。
相反,使用替换(一种模式," _")和所有模式阵列。
注意:没有歧义!
像那样:for (int i=0;i<sA.length; i++)
s=s.replace(sA[i],"-");
等