- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
NSError* utilitiesCheckEmail(NSString* string)
{
NSInteger email_symbol_count=0;
NSInteger pos_email_symbol=0;
NSInteger pos_point=0;
NSInteger count=string.length;
if(count!=0)
{
unichar buffer[count];
[string getCharacters:buffer];
for(NSInteger i=0;i<count;i++)
{
unichar ch=buffer[i];
if( !( (ch>='a') && (ch<='z') ) && !( (ch>='A') && (ch<='Z') ) && !( (ch>='0') && (ch<='9') ) && (ch!='_') && (ch!='-') )
{
switch (ch)
{
case '@':
{
email_symbol_count++;
pos_email_symbol=i;
break;
}
case '.':
{
pos_point=i;
break;
}
default:
return [NSError errorWithDomain:NULL error:eErrorEmailInvalidFormat];
}
}
}
if( (email_symbol_count==1) && (pos_point!=0) && (pos_point>pos_email_symbol) && ((pos_point+1)<count) )
return NULL;
}
return [NSError errorWithDomain:NULL error:eErrorEmailInvalidFormat];
}
codemonkey 25.01.2016 15:40 # 0
А в целом не такое уж и говно, лучше чем RFC-compliant regex.
guest 29.01.2016 15:21 # 0
Coq 19.08.2021 00:01 # 0
TwitterGovno 19.08.2021 00:11 # 0
guest6 19.08.2021 00:14 # 0
TwitterGovno 19.08.2021 00:16 # 0
CocaColaGovno 10.03.2022 21:09 # 0
aderyabin 24.08.2021 23:53 # 0
Tim_Walker 25.08.2021 19:35 # 0