Abhijeet Sakalker(deleted)
|
Unable to get regex functions working
|
Abhijeet Sakalker(deleted)
04/16/2012 10:22 PM
post92574
|
Unable to get regex functions working
I have a simple funciton which performs password validation for atleast 1 UpperCase, 1 LowerCase and 1 Numeric in the
string provided by user as password.
For this am using the regex functions that QNX provides. I have provided a sample function below.
Am providing the following Regex pattern and datastring for validation:
pszRegexPattern : "^.*(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).*$"
pszDataString : "Admin1"
When I call the funciton with these arguments I get that the data string does not match regex pattern, whereas when i
try the same validation on Windows I get a success.
Can anyone please tell me what i might be missing on QNX?
#include <regex.h>
bool ValidateUsingRegex(const schar* pszRegexPattern,
const schar* pszDataString)
{
bool bStrValid = false;
sint32 iResult = EOK;
regex_t obRegexPattern;
char errorBuffer[512U];
if ((0U == regcomp( &obRegexPattern, pszRegexPattern, REG_NOSUB)))
{
printf("Successfully created %s", obRegexPattern.re_endp);
if((iResult = regexec(&obRegexPattern, pszDataString, 0, NULL, 0)) == 0U)
{
bStrValid = true;
printf("ValidateUsingRegex: String %s Validated", pszDataString);
}
else
{
regerror(iResult, &obRegexPattern, errorBuffer, sizeof errorBuffer);
printf("ValidateUsingRegex: Failed %s (%s)\n",errorBuffer, pszDataString);
}
}
else
{
regerror(iResult, &obRegexPattern, errorBuffer, sizeof errorBuffer);
printf("ValidateUsingRegex: RegComp() Error Num %x -> %s (%s)\n",iResult,errorBuffer,pszRegexPattern);
}
regfree(&obRegexPattern);
return bStrValid;
}
|
|
|