void CdlgTestDlg::OnBnClickedOk()
{
regex pattern("(\\d{6})(\\d{4})(\\d{2})(\\d{2})(\\d{4})");
string str_1 = "420121190010055421";
smatch mat;
//取生日
if(regex_search(str_1,mat,pattern))
{
char* pData = new char[50];
string strYear,strMonth,strData;
strYear = mat[2].str();
strMonth = mat[3].str();
strData = mat[4].str();
}
//遍历 /*for(smatch::iterator iter=mat.begin() ; iter!=mat.end() ; ++iter) { string str = iter->str(); CString strTermp(str.c_str()); OutputDebugString(strTermp); }*/ return ; }
原文链接:https://www.f2er.com/regex/358949.html