String fdbs = "WXB,WXA,FDA,WXB"; String[] str = fdbs.split(","); Set set = new HashSet(); for (int i = 0; i < str.length; i++) { set.add(str[i]); } str = (String[]) set.toArray(new String[0]); for (int i = 0; i < str.length; i++)
import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @author lei * 2011-9-2 */ public class StringUtils { public static String replaceBlank(String str) { String dest = ""; if (str!=null) { Pattern p = Pattern.compile("\\s*|
Qualys项目中写到将ServerIP以“,”分割后插入数据库并将重复的IP去除后发送到服务器进行Scan,于是我写了下面的一段用来剔除重复IP: //CR#1796870 modify by v-yangwu, remove the IPs which are repeated. string[] arrayIP = ipAll.Split(','); List<string> listIP = new List<string>(); foreach (string ip in
import java.util.ArrayList; import java.util.Collections; import java.util.List; public class StringUtil { public static String[] stringSort(String [] s) { List<String> list = new ArrayList<String>(s.length); for (int i = 0; i < s.length; i
String regEx="[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}[]‘::”“’., .?]"; //可以在中括号内加上任何想要替换的字符,实际上是一个正则表达式 String aa = " ";//这里是将特殊字符换为aa字符串," "代表直接去掉 Pattern p = Pattern.compile(regEx); Matcher m = p