I wanted to know if my re.search
string, which is repetitive, could be cleaned up.
The code: re.search(r"^([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$"
As you can see, the line ([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])
is being used 4 times, and I feel like it could be shortened by assigning it to a variable? But I have no clue on how to use variables in this string.
If you could, please do explain the code as well, which would be greatly appreciated! Thanks in advance!