10.02.2011, 20:46
I do not have the answer to your exact problem but I tried building my own IsValidEmail modeled after yours and tested it using your 4 emails. You could probably compare my function with yours and find out the problem.
Function:
Test code:
Test Results:
1 = true
0 = false
Function:
pawn Код:
stock IsValidEmail(email[])
{
new a_count, length = strlen(email);
if(length < 5)
return false;
for(new i = 0; i < strlen(email); i++)
{
if(email[i] == '@')
{
a_count++;
if(a_count > 1)
{
return false;
}
}
if( (email[i] < 'A' && email[i] > 'Z') || (email[i] < 'a' && email[i] > 'z') )
{
if(email[i] != '.')
{
return false;
}
}
if(i == length-1 && email[i] == '.')
return false;
}
return true;
}
pawn Код:
printf("%d", IsValidEmail("kwarde@rpdsamp.nl"));
printf("%d", IsValidEmail("kwarde@rpdsamp.nl."));
printf("%d", IsValidEmail("kwa*de@@rpdsamp.nl"));
printf("%d", IsValidEmail("kwarde@rpdsamp.nl"));
1 = true
0 = false
Код:
1 0 0 1