Advertisement
DraKiNs

[COD] Validar Email Pawn

Aug 9th, 2011
718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.03 KB | None | 0 0
  1. /*
  2.  * Validador de Email em Pawn (algorítimo Simples e Eficiente)
  3.  * Copyright (C) 2011 Bruno da Silva <brunoemail@r7.com>
  4.  * www.ips-team.blogspot.com - [iPs]TeaM
  5. */
  6.  
  7. //]]]]]]]]]]]]]]]]]]]]] Função ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
  8.  
  9. isEmail(email[])
  10. {
  11.     if (!email[0]) return false;
  12.  
  13.     new
  14.         len = strlen(email),
  15.         arroba = 0,
  16.         ponto = 0;
  17.  
  18.     for( ; arroba != len; arroba++) {
  19.         if(!(email[arroba] - 64)) {
  20.             for( ponto = arroba; ponto != len; ponto++) {
  21.                 if(!(email[ponto] - 46)) {
  22.                     break;
  23.                 }
  24.             }
  25.             break;
  26.         }
  27.     }
  28.     return (arroba + 1 < ponto < len && ponto && arroba);
  29. }
  30.  
  31. //]]]]]]]]]]]]]]]]]]]]] Exemplos ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
  32.  
  33.     printf("brunosilva@r7.com %d", isEmail("brunosilva@r7.com"));
  34.     printf("brunosilva@.com %d", isEmail("brunosilva@.com"));
  35.     printf("@aaa.com %d", isEmail("@aaa.com"));
  36.     printf("bb@bbb. %d", isEmail("@aaa.com"));
  37.     printf(".com %d", isEmail("@aaa.com"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement