c++正则表达式

  匹配数字

#include "stdafx.h"
#include <regex>
#include <string>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    std::string s("System20171226.log");
    std::smatch m;  
    std::regex e("([0-9]{8})");

    std::regex_search(s, m, e);
    std::cout << m.str() << std::endl;  //输出匹配结果  
    
    
    getchar();
    return 0;
}

判断是否为真

CString css="System2018-01-02.log";
string str;  
str = (LPCSTR)(CStringA)(css);
std::regex regPattern(REG_DATE);
BOOL bValid2 = std::regex_search(str, regPattern);