0

How can i tell if a String contains a IPv4 address. I want to get all IP Addresses in this string.

Exemple:

The following string contains 4 IPv4 Addresses:

2016-01-16 00:00 - [99.245.14.88] downloaded ...
2016-01-16 00:00 - [120.103.139.95] downloaded ...
2016-01-15 23:59 - [166.118.4.233] downloaded ...
2016-01-15 23:59 - [55.234.129.191] downloaded ...
Bilal HIMITE
  • 45
  • 11
  • Possible duplicate of [How do you extract IP addresses from files using a regex in a linux shell?](http://stackoverflow.com/questions/427979/how-do-you-extract-ip-addresses-from-files-using-a-regex-in-a-linux-shell) – Alessandro Da Rugna Jan 16 '16 at 16:17

1 Answers1

0

Here is some code I just made to get you each IP..

    Dim Regex As New System.Text.RegularExpressions.Regex("\[(([\d]{1,3}\.?){4})\]", System.Text.RegularExpressions.RegexOptions.Multiline)
    Dim matches As System.Text.RegularExpressions.MatchCollection = Regex.Matches(TextBox1.Text) 'Replace textbox with your string source

    Dim tmp As String = ""
    For Each match As System.Text.RegularExpressions.Match In matches
        'Do something with each IP : match.Groups(1).Value
        tmp &= match.Groups(1).Value & vbNewLine
    Next

    MsgBox(tmp)

It uses a regular expression, If you are going to work with text a lot you should read about how they work. If this is what you were looking for don't forget to mark as the answer and upvote.

myekem
  • 139
  • 8