in reply to Regex to match an IP address that is embedded inside of another string
Is the colon always going to be in place after the last octet? With /\d+\.$oc1\.$oc2\.$oc3\.$oc4\:*/, first, you don't need to escape the colon, and second, you use *, so that means 0 or more. That means that it'll ignore the colon if it means a longer match. The following will match the 4th octet exactly before the colon, or it won't match at all:
/\d+\.$oc1\.$oc2\.$oc3\.$oc4:/
|
|---|