[英]Splitting Words Based on Array of String in Java
I have a static array consist of some arrays of strings 我有一个静态数组,其中包含一些字符串数组
String str = ""; String[] sA = { "ai", "au", "oi" }; String[] sB = { "b", "c", "d" }; String[] sC = { "th", "ng", "sy" };
How to split a sentence based on these arrays of strings to add different punctuation from each array of string after splitting to string str? 在拆分为字符串str后,如何基于这些字符串数组拆分句子以在每个字符串数组中添加不同的标点符号? eg :
例如:
String s = "This ball color is beautiful";
Result if sA's split punctuation is '-', sB's split punctuation is '_', sC's split punctuation is '=': 结果:如果sA的分割标点为'-',sB的分割标点为'_',sC的分割标点为'=':
str = "=is _all _olor is _e-tiful";
Any help would be appreciated! 任何帮助,将不胜感激!
You dont split, finally. 最后,你不分裂。
Rather, use replace (one pattern,"_") with all your arrays of pattern. 而是,对所有模式阵列使用replace(一个模式,“ _”)。
Beware: no ambiguity ! 当心:没有歧义!
like that: 像那样:
for (int i=0;i<sA.length; i++)
s=s.replace(sA[i],"-");
etc. 等等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.