Let's say I have 3 strings:
str1 = 'Hello my name is Ben and my IP address is 127.1.1.1'
str2 = 'Hello my name is Folks and my IP address is 1.2.3.4.5'
str3 = 'Hello all, ip addresses: 1.2.3.4.5, 127.1.2.1, 127.2.1.2'
I would like to get the following output:
find_ip(str1) #['127.1.1.1']
find_ip(str2) #[]
find_ip(str2) #['127.1.2.1', '127.2.1.2']
- Criteria:
- IM addresses with the following form 'x.x.x.x'
- Regex should be 1 group.
- The number of digits doesn't matter (111.111.111.111) is good.
P.S The solution of this StackOverflow post does NOT answer this question.