Java中基于字符串数组的分词
我有一个静态数组,由一些字符串数组组成 String str = ""; String[] sA = { "ai", "au", "oi" }; String[] sB = { "b", "c", "d" }; String[] sC = { "th", "ng", "sy" }; 字符串str=“”; 字符串[]sA={“ai”,“au”,“oi”}; 字符串[]sB={“b”,“c”,“d”}; 字符串[]sC={“th”,“ng”,“sy”}; 如何基于这些字符串数组拆分句子,以便在拆分到string str后从每个字符串数组中添加不同的标点符号? e、 g: String s=“这个球的颜色很漂亮”; 结果如果sA的拆分标点符号为“-”,sB的拆分标点符号为“u”,sC的拆分标点符号为“=”: str = "=is _all _olor is _e-tiful"; str=“=is _all _coloris _e-tiful”;Java中基于字符串数组的分词,java,string,split,Java,String,Split,我有一个静态数组,由一些字符串数组组成 String str = ""; String[] sA = { "ai", "au", "oi" }; String[] sB = { "b", "c", "d" }; String[] sC = { "th", "ng", "sy" }; 字符串str=“”; 字符串[]sA={“ai”,“au”,“oi”}; 字符串[]sB={“b”,“c”,“d”}; 字符串[]sC={“th”,“ng”,“sy”}; 如何基于这些字符串数
任何帮助都将不胜感激 你终于不分手了 相反,使用replace(一个模式,“"”)替换所有模式数组 注意:不要含糊不清 就像这样:
for (int i=0;i<sA.length; i++)
s=s.replace(sA[i],"-");
对于(int i=0;iI在这里看不到任何分割,但是使用-
从数组中包围元素。除了使用String[]splitS=line.split(“ai | au | | oi”);以及line.split(“ai | ao | oi”)
(除了数组中没有ao
之外)我需要使用字符串的许多条件进行拆分,以便在拆分完成后添加标点符号,但您仍然没有描述编写代码时面临的问题。您需要询问特定的问题(以及要求!=问题)。
for (int i=0;i<sA.length; i++)
s=s.replace(sA[i],"-");