|
> vlan access-log ratelimit 2000
> vlan 220-221,306
> vlan 2105-2107,3100-3103
↑もし「vlan 」のあとの1文字が数字だったら【取得】
a のように数字でなかったら【スキップ】
ということであれば、
------------------------------
Sub Try4()
Dim io As Integer
Dim myLogFile As String: myLogFile = "E:\(Data)\temp8Log\hoge.log"
Dim buf() As Byte
Dim ss() As String, s As String, Series, num As Long
Dim hostname As String, ok As Boolean
Dim i As Long, j As Long
Dim rex As RegExp
Dim mm As Match
Set rex = New RegExp
io = FreeFile()
Open myLogFile For Binary As io
ReDim buf(1 To LOF(io))
Get io, , buf
Close io
ss = Split(StrConv(buf, vbUnicode), vbCrLf)
With rex
.Pattern = "[\d-]+"
.Global = True
For i = 0 To UBound(ss) - 1
If Not ok Then
If ss(i) Like "hostname*" Then
hostname = Split(ss(i))(1)
Debug.Print , "hostname", "vlan ID"
ok = True
End If
ElseIf ss(i) Like "vlan*" Then
If Mid$(ss(i), 6, 1) Like "#" Then '◆条件追加
For Each mm In .Execute(ss(i))
s = mm.Value
If s <> "-" Then
Series = Split(s, "-")
num = Series(0)
For j = num To Val(Series(UBound(Series)))
Debug.Print , hostname, j
Next
End If
Next
End If
End If
Next
End With
End Sub
#Try4()実行結果
-------------------------------------
hostname vlan ID
ABC 220
ABC 221
ABC 306
ABC 2105
ABC 2106
ABC 2107
ABC 3100
ABC 3101
ABC 3102
ABC 3103
|
|