Rinto Andrews Rinto Andrews - 12 days ago 4x
iOS Question

Regex to Check Numbers, Space, ( ) +

I am writing a IOS app , for that i need regx to detect Numbers, Space , ( ) +

[newText isMatchedByRegex:@"^(?:|0|[1-9]\\d*)(?:\\.\\d*)?$"]


You can find the whitespace through this below code,

 NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];

And you can find the number by,

-(BOOL)only_number :(NSString *)text_string
      NSCharacterSet* notDigits = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
      if ([text_string rangeOfCharacterFromSet:notDigits].location == NSNotFound)
            return FALSE;
            return TRUE;


Note: Here the Key is NSCharacterSet.