I have a string that is a list of IP addresses and an important number.
I'm trying to parse the string, such that it only includes the IP address. Or better yet, create multiple strings depending on how many IP addresses are denoted.
I feel like I'm close, but no cigar.
Input:
$str = "[11.22.33.44]-30,[55.66.77.88]-30"
Expected Output:
11.22.33.44
55.66.77.88
My first iteration at solving this using regex:
while ($tempBlackList =~ /(\w+)/g) {
print "$1\n";
}
This results in:
11
22
33
44
30
55
66
77
88
30
Second Iteration of trying to solve this:
while ($tempBlackList =~ /(\w+)(\w+)(\w+)(\w+)/g) {
print "\"$1.$2.$3.$4\n";
}
This results in nothing being printed. I expected it to be what I wanted.
Any help would be appreciated.