- Original Message -
From: "Toby Stuart" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 11, 2002 10:57 PM
Subject: regex question
> Hi All,
>
> I have the following lines in a file
>
>
> Some Client - ABC - DEF
> Some Other Client - XYZ
> Another Client
>
>
> I need
my @strings = qw( hello\] hi_there] how_are_you2\] fine-and-you\]
good_thanks]);
for(@strings){
my $matched = /(.*)\\*?\]$/;
if( $matched )
{
print "matched! - $1 \n"
}
else
{
print "no match - $1 \n"
}
}
matched! - hello\
matched! - hi_there
matched! - how_are
Not sure what you're trying to do, but
if you wish to split into strings at
the pont ] or \] then just use the
split command to split at that string.
Put the string in an 'or' block, signified
in for perl regex engine as (a|b), where
both a and b represent a string, in your
case ] and \], though y
t;
To: "Perl-Win32 (E-mail)" <[EMAIL PROTECTED]>
Sent: Wednesday, June 13, 2001 3:46 PM
Subject: RE: regex question...
> If you really want a 'correct' IP, you could use this:
>
> $ip_addr =~
> /^(([01]?\d\d?|2[0-4]\d|25[0-5])\.){3}([01]?\d\d?|2[0-4]\d|25[0-5]
Tim Hammerquist wrote:
>
> "$Bill Luebkert" wrote:
> >
> > "Schiza, Apostolia (ISS Atlanta)" wrote:
> > >
> > > Hi,
> > > in one of my perl scripts I am trying to check for a valid ip address,
> > > ie in the format of XXX.XXX.XXX.XXX where x of course is digit,
> > > and you can have ips with ea
"$Bill Luebkert" wrote:
>
> "Schiza, Apostolia (ISS Atlanta)" wrote:
> >
> > Hi,
> > in one of my perl scripts I am trying to check for a valid ip address,
> > ie in the format of XXX.XXX.XXX.XXX where x of course is digit,
> > and you can have ips with each feild having 1-3 digits
> > This is th
If you really want a 'correct' IP, you could use this:
$ip_addr =~
/^(([01]?\d\d?|2[0-4]\d|25[0-5])\.){3}([01]?\d\d?|2[0-4]\d|25[0-5])$/
This RegEx (based on page 124 of "Mastering Regular Expressions", O'Reilly)
forces the numbers to be in the range 0 - 255. There is one, and only one
problem
"Schiza, Apostolia (ISS Atlanta)" wrote:
>
> Hi,
> in one of my perl scripts I am trying to check for a valid ip address,
> ie in the format of XXX.XXX.XXX.XXX where x of course is digit,
> and you can have ips with each feild having 1-3 digits
> This is the regex I am using:
>
> $ip_addr =~ m/\
> $parts[2] =~ s/<.?[td|table|tr](.*)>//g;
[] is a character class, you are telling Perl to match a 't' or a 'd' or
a '|' or an 'a', etc.
$parts[2] =~ s/<.?(?:td|table|tr)(.*?)>//g;
Should fix the problem of everything being deleted. I recall there being
a HTML::TableExtract module which you co