see my comments at bottom...

-----Original Message-----
From: Shaun Bramley [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 24, 2002 4:39 PM
To: [EMAIL PROTECTED]
Subject: Regular Expression help


Hi all.

I am hoping that someone can help me determine what is wronf with my regualr
expression.

background info: @array contains 'text', numbers, INT, or TINYINT.

I am trying to identify if the array element is a number.

What I have right now is:

if($array[$x] =~ /\d{1,3}?/)
{
.....do something
}

Unfortunately this if statement never appears to come true.

thank you

Shaun

-----Response Follows------

I'm not clear on what your problem is.  Could you give some examples of what
in the array you want to "do something", and some examples that you don't?
Perhaps show us more of the code than just the regexp?

I quickly wrote up the following code (using your regexp):

push @array,'1';
push @array,'xyzzy';
push @array,'1.234';
push @array,"0x1234";
push @array,3;

for ($x=-1;$x++<$#array;) {
    if ($array[$x] =~ /\d{1,3}?/) {
        print "Yes: "
    } else {
        print "No : "
    }
    print $array[$x]."\n";
}

which produces:
Yes: 1
No : xyzzy
Yes: 1.234
Yes: 0x1234
Yes: 3

which appears to me to be correct.

                                /\/\ark


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to