You could use some lookarounds to help make sure there are no other .
around the IP:
(?<!\.)\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b(?!\.\d)
(?<!\.)
makes sure there's no dot before the IP and (?!\.\d)
makes sure there's no .
after the IP and a number. I added a number because I think you could have an IP followed by a dot if that last dot is meant to be the period of the end of a sentence.
The word boundaries (\b
) prevent matching between numbers.