thendal
Programmer
- Aug 23, 2000
- 284
Hi all!
How i will be able to grab first six character from a string and then check the first 6 character string to have atleast two alphabetic charater and atleast one digit.
I tired something like this ...
$test="thisistest";
@array1=split(//,$test);
for($i=0;$i<6;$i++)
{
$sixcharacter=$sixcharacter.$array1[$i];
}
# I know there is much easier method than this..
# to check the atleast two alphabetic character and a digit
if((!($sixcharacter=~/\d/))&&(!($sixcharacter=~/[a-z]/i)))
{
print "Need atleast one digit & two alphabetic character");
}
I got the digit part correct , to check atleast two alphabetic character need a better regular experssion.
Any thoughts ...
Thank you.
How i will be able to grab first six character from a string and then check the first 6 character string to have atleast two alphabetic charater and atleast one digit.
I tired something like this ...
$test="thisistest";
@array1=split(//,$test);
for($i=0;$i<6;$i++)
{
$sixcharacter=$sixcharacter.$array1[$i];
}
# I know there is much easier method than this..
# to check the atleast two alphabetic character and a digit
if((!($sixcharacter=~/\d/))&&(!($sixcharacter=~/[a-z]/i)))
{
print "Need atleast one digit & two alphabetic character");
}
I got the digit part correct , to check atleast two alphabetic character need a better regular experssion.
Any thoughts ...
Thank you.