我有一个REGEX循环,可以找到某些字符串(Match.value
在下面的代码中)。我需要使用4个不同的REGEX对循环执行4次,并在找到四个REGEX循环中的每个匹配项时累积构建数组。
我已经可以用匹配项填充一维数组,但是我不知道如何将其他信息(与每个匹配项关联的所有静态文本/字符串)添加到其他维度。我希望最终得到这样的结果:
匹配值| String1_here | String2_here | String3_here | String4_here
Dim serialArray() As String
For Each Match in theMatches
Redim Preserve serialArray(x)
serialArray(x) = Match.value
x = x + 1
Next Match
尝试以下...
With theMatches
If .Count > 0 Then
ReDim serialArray(1 To .Count, 1 To 5) 'allocate storage space for an N X 5 array
x = 1
For Each Match In theMatches
serialArray(x, 1) = Match.Value
serialArray(x, 2) = "String1"
serialArray(x, 3) = "String2"
serialArray(x, 4) = "String3"
serialArray(x, 5) = "String4"
x = x + 1
Next Match
End If
End With
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句