I want to have only 13 numeric values or the 13numeric values can be prefixed with "+" sysmbol.so the + is not mandatory Example : 1234567891234 another example is : +1234567891234
I have tried the above link , but this +1234545 but i want to have only 13 numarals or + can be prefixed with that 13 numerals.
Please let me know , what can i change it here
This is the code i tried
NSString * forNumeric = @"^\\+(?:[0-9] ?){6,14}[0-9]$";
BOOL isMatch = [[textFieldRounded text] isMatchedByRegex:forNumeric];
if (isMatch == YES){
NSLog(@"Matched");
}
else {
NSLog(@"Not matched");
}
^(\+?)(\d{13})$
should do the trick, escape the slashes for objective-C usage.
13 digits, with an options +
prefix.
If you want to play with regexp expressions you can use services like this one for visual feedback, very handy.
NSString * forNumeric = @"^(\\+?)(\\d{13})$";