相同字符串视为相同字符,去除相同字符串
public List<String> removeSameStr() {
List<String> list = new ArrayList<>();
List<String> result = new ArrayList<>();
list.add("123abccd");
list.add("abcdc123");
list.add("1234abc");
list.add("ab1234cd");
for (int i = 0; i < list.size(); i++) {
String w = Pattern.compile("[^0-9]").matcher(list.get(i)).replaceAll("");
for (int j = i + 1; j < list.size(); j++) {
String t = Pattern.compile("[^0-9]").matcher(list.get(j)).replaceAll("");
if (w.equals(t)) {
// 随便取一个
result.add(list.get(i));
}
}
}
return result;
}
标签:数字串,相同,get,List,视为,list,add,result
From: https://www.cnblogs.com/fchhk-blog/p/17383173.html