I want to find log files ending with “access” and a number, such as 500m-access0.log
.
My code :
bool is_access_log(const char *file_name)
{
std::string name(file_name);
struct stat file_info;
if (stat(file_name, &file_info) < 0 || S_ISDIR((&file_info)->st_mode))
{
// return false if dir
return false;
}
std::regex reg("(.)(-access)(\d).log");
return std::regex_match(file_name, reg);
}
but I got false
when I use 500m-access0.log
and any_name-access3.log