这是字符串的一部分
471 pfm9254-disk01_01 0 io_grp0 online 3 Chassis2_IBMi 100.00GB striped 0 fcmap0 60050768028080EF6400000000001391 1 1 empty 0 no 0
472 IP10-32-41-70_SLES11SP2_10G 0 io_grp0 online 0 pfm3079_pfm3128 10.00GB striped 60050768028080EF64000000000007CE 0 1 empty 0 no 0
473 pfm3128_pva1091_stgvios1 0 io_grp0 online 1 VIOS_StgPool 35.00GB striped 60050768028080EF64000000000007D1 0 1 not_empty 0 no 0
474 vdisk64 0 io_grp0 online 13 pfm9253_pfm9254_new 9.94GB striped 60050768028080EF6400000000001CC4 0 1 empty 0 no 0
475 vdisk65 0 io_grp0 online 13 pfm9253_pfm9254_new 10.00GB striped 60050768028080EF6400000000001CC6 0 1 empty 0 no 0
我想检查它是否包含我的 arrayList 的任何成员
我知道我可以迭代 arrayList,然后检查每个元素该字符串是否包含该元素。我正在寻找有效的解决方案
这是我的数组列表
ArrayList<String> volIDsSent = new ArrayList<String>();
volIDsSent.add("60050768028080EF6400000000000AC3");
volIDsSent.add("60050768028080EF6400000000000FF8");
我会从某处逐行获取字符串。
最佳答案
考虑读取一次数组并通过连接“|”来构建正则表达式字符串在每个之间,手动或使用诸如 StringUtils.join 之类的东西。然后对每一行使用正则表达式来读取。
关于java - 检查字符串是否包含 arrayList 的任何成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19566937/