This program is trying to get the starting and ending IP from user input.
User Input Sample
Case 1. 10.244.1.0-100
Case 2. 10.244.1.0-11.245.0.1
For Case 1, the starting IP should be 10.244.1.0 while ending ip is 10.244.1.100
For Case 2, the starting IP should be 10.244.1.0 while ending ip is 11.245.0.1
Note that, form 1 can be 10.244.1.2-1 and form 2 can be 11.245.0.1-10.244.1.0
IPv4 Regex validate
1 | def is_valid_ipv4(ip): |
Determine the starting and ending IP
1 | def find_start_end_ip(first_ip, second_ip): |
Main program
1 | import re |
Test Case Input:
1 | test_case_list = ['10.244.1.0-256', |
Test Case Output:
1 | Input case 1 |
Tools / Acknowledgements
IP Address Regex: https://www.regular-expressions.info/ip.html
Regex Testing Online: https://regexr.com/