Advertisement
Johurt

[FNC] IsCorrectMail

Feb 23rd, 2013
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.90 KB | None | 0 0
  1. /*
  2.         Author: Johurt(ES.^, Edgar).
  3.         Date: 23-02-2013.
  4. */
  5.  
  6. stock IsCorrectMail(mail[])
  7. {
  8.     new len = strlen(mail), bool:find[2], w;
  9.     if(!(6 < len < 129)) return false;
  10.     for(new l; l < len; l++)
  11.     {
  12.         if(mail[l] == '.') find[0] = true;
  13.         if(mail[l] == '@')
  14.         {
  15.             if(find[1]) return false;
  16.             find[1] = true;
  17.             w = l;
  18.             if(w > 64) return false;
  19.         }
  20.         if(!(mail[l] >= 'A' && mail[l] <= 'Z' || mail[l] >= 'a' && mail[l] <= 'z' || mail[l] >= '0' && mail[l] <= '9' || mail[l] == '.' || mail[l] == '-' || mail[l] == '_' || mail[l] == '@')) return false;
  21.     }
  22.     if(len - w > 65) return false;
  23.     if(!find[0] || !find[1]) return false;
  24.     return true;
  25. }
  26.  
  27. /*   Example   */
  28. main()
  29. {
  30.     print("\n\n\n");
  31.     printf("Mail test@mail.com: %s", IsCorrectMail("test@mail.com") ? ("Correct") : ("Incorrect"));
  32.     printf("Mail a@b.c: %s", IsCorrectMail("a@b.c") ? ("Correct") : ("Incorrect"));
  33.     print("\n\n\n");
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement