Alexander Bartolich said:
begin followup to Jeremy Yallop:
Because it's fun.
perl -ne 'm/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/ && print $&' < data
Not really. The above solution recognizes many things that look like
IP addresses, but are invalid. It may also fail to recognize some
things that are valid IP addresses. I won't go into the details,
because this (a) isn't the right place for it, and (b) I'm not sure of
the exact definition of a valid IP address (or, rather, of the textual
representation of a valid IP address).
The use of Perl is obviously off-topic, but a complete response would
require discussion of the RFC or RFCs that define the format, and
would probably veer off into IPV6 issues as well. If I tried to
discuss it here, I would miss the opportunity to have my inevitable
mistakes corrected by experts.
C has no built-in support for regular expressions, though of course
numerous regular expression packages have been written in C.
If you want to present a definition of a valid IP address and ask how
to recognize strings that match the definition in portable C, this is
the place to discuss it -- ideally by posting a short working code
sample and asking why it doesn't work. Otherwise, there are more
appropriate newsgroups.