+ 3

regular-expression-problem with identifying all ip addresses in a text string

We assume for simplification that ip address has common pattern of x.x.x.x where x is a number consisting of 1 to 3 digits in the range of 0 to 9. I have made a program here: https://code.sololearn.com/c2LK1O0V6tWj/?ref=app Could anybody spot the mistake(s) that the program prints all potential ip addresses which match the above described pattern in the text string? The program should return something like ['1.12.123.123', '2.2.2.2', '1.1.1.1']

19th Oct 2019, 5:11 AM
Jan Markus
2 ответов
+ 6
Taking reference from my answer posted in your other thread, (?:[0-9]{1,3}\.){3}[0-9]{1,3} will give you the desired output. https://www.sololearn.com/Discuss/2041464/?ref=app
19th Oct 2019, 7:17 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
Hatsy Rei Thank you very much! 😊
19th Oct 2019, 8:42 AM
Jan Markus