-
Emilia Simonyan 76 Reputation points
2022-12-27T06:18:09.253+00:00 Hi,
So, if you have a table named 'tickets', and a column named 'subject', you can use this querySELECT subject, SUBSTRING(subject, PATINDEX('%..._%', subject), 14) as ip_address
FROM tickets
Hi,
I think you can use a simple formula (MID) either in Excel or VBA to extract the IP address.
Something like this would probably work:
=Mid(A1;FIND("."; A1)-3;14)
or
Mid(Selection, InStr(Selection, ".") - 3, 14)
Alternatively, you could use regex in VBA to find IP address pattern within the text (first, you would need to enable Microsoft VBScript Regular Expressions).
Please, see this example:
Sub test()
Dim RegEx As Object
Dim Match As Object
Dim MyString As String
Dim c As Integer
Set RegEx = New RegExp
RegEx.Pattern = "[\s]?([\d]{3}[.][\d]{2}[.][\d]{3}[.][\d]{3})[\s]?"
RegEx.Global = True
MyString = "111.12.123.227 Server is down"
Set Match = RegEx.Execute(MyString)
For c = 0 To Match.Count
Debug.Print Match(c).Value
Next c
End Sub
Hope this helps.