언어 설정

Menu
Sites
Language
Validate Phone Numbers

How can we validate phone numbers in Tizen native application?

I've tried validating a phone number in Tizen with the help of following code
 

regex_t regex;

reti = regcomp(&regex, "^((\\+91)|0?)[789]{1}\\d{9}$", 0);

reti = regexec(&regex, phoneNumber, 0, NULL, 0);

But the above code  doesn;t work for me, both the functions regcomp and regexec are giving error code number -126, can anyone tell me where the problem is?

 

Thanks.

Responses

3 댓글
colin Rao

Hi,

How did you find the regexp api, I don't face such regexp api in help doc, I am using Tizen SDK Rev2.

What's the header file as your code? regex_t regex.

Vivek Chandra Amancha

it's regex.h, it is from GNU C.

How do you validate phone numbers?

colin Rao

Hi, 

I am run your sample code on my local environment, seems it's ok.

As below code, I get error code 0 for regcomp, and get error code 1 for regexec, but as the error code definition, seems the 1 means don't find a match.

  REG_NOERROR = 0,    /* Success.  */
  REG_NOMATCH,        /* Didn't find a match (for regexec).  */

regex_t regex;
int ret;
char *phoneNumber = "+91789125863571";

ret = regcomp(&regex, "^((\\+91)|0?)[789]{1}\\d{9}$", REG_EXTENDED|REG_NEWLINE|REG_ICASE);

ret = regexec(&regex, phoneNumber, 0, NULL, 0);