in reply to RE: RE: Getting an IP out of a string
in thread Getting an IP out of a string

The problem is that what is or is not an IP address really depends on the file semantics, not just on what an IP address "looks like." A simple regex match for dotted-quad "IP addresses" in arbitrary text will give you false positives.

In the HTML source for one site I maintain, for example, such a regex would match the following:
1.41.1.1
Is it an IP address? Nope, it's an RCS version number, and blindly assuming it's an IP address would be wrong at best and dangerous at worst.

That said,
@ip_addrs = m/{regex to match IP}/g;
will select only the "IP address" texts from $_ for whatever regex you choose, without the danger of relying on $1.

Replies are listed 'Best First'.
RE: RE: RE: RE: Getting an IP out of a string
by the_slycer (Chaplain) on Aug 17, 2000 at 19:33 UTC
    Thank you, that is exactly what I needed.

    And, yes, I prompt the user of the script to ensure the strings it has chosen from an html file are indeed ones that currently contain IP addresses, and are ones they would like updated in the future :-)
    ie: I'm not relying on my shoddy coding alone.