-(IBAction)web
id)sender
{
NSString *web =[[NSString alloc]initWithString:[webfield stringValue]];
NSString *webRegEx = @"www.[A-Z0-9a-z._%+-]+.[a-z]{2,4}";
NSPredicate *webTest = [NSPredicate predicateWithFormat
"SELF MATCHES %@",webRegEx];
if ([webTest evaluateWithObject:web] == YES)
{
[NSApp beginModalSessionForWindow:valid];
[webfield web:sender];
}
else
{
[NSApp beginModalSessionForWindow:notvalid];
[webfield setStringValue
""];
[webfield web:sender];
}
}
when this code is used www.hai.com , wwwww.fff.com , wwwfghw.hai.com , these format are shown valid and also the letter 'w' can used any number of times and also other letters are also accepted .
I need a standard format ie: www.hhhh.com , the w should appear only three times otherwise it must not be valid.
How can it be poosible ? please help
thakyou
{
NSString *web =[[NSString alloc]initWithString:[webfield stringValue]];
NSString *webRegEx = @"www.[A-Z0-9a-z._%+-]+.[a-z]{2,4}";
NSPredicate *webTest = [NSPredicate predicateWithFormat
if ([webTest evaluateWithObject:web] == YES)
{
[NSApp beginModalSessionForWindow:valid];
[webfield web:sender];
}
else
{
[NSApp beginModalSessionForWindow:notvalid];
[webfield setStringValue
[webfield web:sender];
}
}
when this code is used www.hai.com , wwwww.fff.com , wwwfghw.hai.com , these format are shown valid and also the letter 'w' can used any number of times and also other letters are also accepted .
I need a standard format ie: www.hhhh.com , the w should appear only three times otherwise it must not be valid.
How can it be poosible ? please help
thakyou