Saturday, 31 August 2013

why is the following code not behving correctly?

why is the following code not behving correctly?

I wrote following piece of code to verify if the input is a valid pan
number using regular expressions. It is returning "NO" for ABCDS1234Y.
void process(string inp)
{
string panex= "[A-Z]{5}[0-9]{4}[A-Z]{1}";
regex panreg(panex,regex_constants::basic);
if(regex_match(inp,panreg))
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
}
http://ideone.com/fgGScw
is there something wrong with compiler or the regular expression.

No comments:

Post a Comment