Tag Archives: system administration

Regexp for extracting public IP address

bigdatamarkRecently I needed to make a regular expression for parsing the first public IPV4 address from a string of comma separated private and public IP addresses.

After spending an hour on it and failing, I thought about it over night and woke up with some more ideas of what to try.

I ended up using a word boundary as an anchor and a negative lookahead from the anchor to accomplish it.

Test string: