Let's assume I have this line in my etc/passwd:
xuser01:*:111000:201:User Name, School Info, Year:/homes/pc/xu/xuser01:/bin/ksh
I browse the file by lines.
From parameters I get usernames/userids that tells me which lines I should store into variable.
Using both regex_match and regex_search I got no results, while when I was testing it on online regex testers, it work like hell. Any idea why this is not working?
regExpr = "^(xuser01|xuser02)+:((.*):?)+";
if(regex_search(line, regex(regExpr)))
{
cout << "Boom I got you!" << endl;
}
line
contains line read at the moment, it loops through the whole file, and doesn't find the string. I used regex_match
too, same results.
Different regular expressions I tried: (xuser01|xuser02)+
and similar, designed to be almost 100% sure match (but still what I need to match), neither of it works in my C++ program, on online regex testers it does.
Advices?
Thanks in advance!