[Israel.pm] extract ip from html

Ran Eilam ran.eilam at gmail.com
Mon Aug 6 15:18:16 PDT 2007

Hey Mr. Ernst!

On 8/6/07, Ernst, Yehuda <yernst at nds.com> wrote:

> I have html with ip addr. inside
> how can i extract it?
> i have in the html
> <td>x.y.z.w</td>
> where x and y and z and w can be 1 2 or 3 digits.

For well known languages probably best use Regexp::Common. Check
out Regexp::Common::net For IP addresses. The tests are beautiful:



try $RE{net}{IPv4};

pass '';
pass '';
pass '';
pass '';
fail '';
fail '255.0.1287.23';
fail '255.a.127.23';
fail '255 0 127 23';
fail '255,0,127,23';
fail '255012723';


Unfortunately, it is only the 5th Google match for "regexp IPv4 address perl",
and some of the ones above it suck.

Strangely, it's the 1st on Microsoft search, but the rest are way off target.

5th on Yahoo. The rest are good, but not related to Perl or the general problem.

Don't know enough of your problem to know if this helps because it may be, as
Oded pointed out, an HTML parsing problem, or even a regexp-HTML-combo.

Hope this helps,


This e-mail is confidential....


At least the corporate signature has the VAT number for Great Britain,
in case we need it ;)

More information about the Perl mailing list