GuitarFan
GuitarFan

Reputation: 27

What patern use for find number in log file?

I have log file Logfile.log:

sometext...
2014/11/05 11:06:11.001  3652  3176 G1   CInterProcessNetwork::SetDyngateIDforSession() id=821130255 session=1 ptype=2
...sometext

I need to get this id "821130255". Which pattern i need to use for VBScript.RegExp?

I'm using this code:

With WScript.CreateObject("VBScript.RegExp")
    .Pattern = "????"

    If .Test(strContent) Then
        strValue = .Execute(strContent).Item(0).Submatches.Item(0)
        WScript.Echo "Found value [" & strValue & "]."
    Else
        WScript.Echo "Can't find pattern [" & .Pattern & "] in content of [" & strSourceFile & "]."
    End If
End With

Upvotes: 0

Views: 35

Answers (1)

vks
vks

Reputation: 67988

\bid=(\d+)

This simple regex should do it for you.See demo.

http://regex101.com/r/iZ9sO5/1

Upvotes: 2

Related Questions