我最初有这样的字符串:(我使用MySQL的GROUP_CONCAT()函数)
oldArrStr = "1, 2, 79, 5, 6, 7"
newArrStr = "4, 6, 2, 13, 7, 9"
我碰巧需要将newArrStr与oldArrStr进行比较,它应该返回匹配值的计数。在这种情况下:oldArrStr和newArrStr都有:2,6,7,所以它应该返回3
提前感谢。
答案 0 :(得分:0)
试试这个:
Dim oldArrStr = "1, 2, 79, 5, 6, 7"
Dim newArrStr = "4, 6, 2, 13, 7, 9"
Dim count = _
oldArrStr.Split(","c).Select(Function (x) x.Trim()) _
.Intersect(newArrStr.Split(","c).Select(Function (x) x.Trim())) _
.Count()
根据你的问题,我得到三个。
你可以摆弄它here。