BOOL CheckNumValid(CString strIn) { wstring szName = strIn.GetBuffer(); strIn.ReleaseBuffer(); std::wregex reg(L"^(([1-9]+\d*)|(0{1}))(.\d{1,2})?"); std::wsmatch result; BOOL bIsValid = regex_match(szName, result, reg); if (!bIsValid) { msgbox(L"请输入数字!"); } return bIsValid; }