|
▼くま さん:
>(2)「vlan 数字」という行をみつけたら数字だけを取り出し
>(3)「hostname ABC」の"ABC"部分だけ取得
Try1()に上の要件を追加してみました
Sub Try2()
Dim io As Integer
Dim myLogFile As String: myLogFile = "E:\(Data)\temp8Log\hoge.log"
Dim buf() As Byte
Dim ss() As String
Dim hostname As String, ok As Boolean
Dim i 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", hostname
ok = True
End If
ElseIf ss(i) Like "vlan*" Then
For Each mm In .Execute(ss(i))
If mm.Value <> "-" Then Debug.Print mm.Value
Next
End If
Next
End With
End Sub
|
|