下面方法你传入一个value并且带逗号的值,你将得到一个逗号分割的List列表,如果是字符串只需要把Integer类型改为string就好了。strs 传入的值将不在List列表里面返回
示例:
value = 23,45,67,89,32,23,50
strs = 50 不在下面List列表里面返回
返回:一个List列表
23
45
67
89
32
23
/**
* @param value 需要截取的字符串
* @param strs 不需要截取的字符串
* @return
*/
public static List<Integer> findStrings(String value, String... strs) {
//以逗号分割,得出的数据存到 result 里面
String[] result = value.split(",");
List<Integer> list = new ArrayList<>();
for (String r : result) {
if (strs != null) {
if (!isBlank(r)) {
if (!r.equals(strs[0]) && !r.equals(strs[1])) {
list.add(Integer.parseInt(r));
}
}
}
if (!isBlank(r)) {
if (isEmpty(strs)) {
list.add(Integer.parseInt(r));
}
}
}
return list;
}