다음 코드가 "일치하지 않음"을 인쇄하는 이유는 무엇입니까? 컴파일러 또는 라이브러리 버전과 관련된 것이 있습니까? 나는 g ++ a.cpp로 컴파일했다.tr1/regex 문제가 있습니다. 반대 결과를 인쇄하십시오
#include <tr1/regex>
#include <iostream>
#include <string>
using namespace std;
int main()
{
const std::tr1::regex pattern("(\\w+day)");
std::string weekend = "Saturday and Sunday";
std::tr1::smatch result;
bool match = std::tr1::regex_search(weekend, result, pattern);
if(match)
{
for(size_t i = 1; i < result.size(); ++i)
{
std::cout << result[i] << std::endl;
}
}else
std::cout << "no match" << std::endl;
return 0;
}
짧은 완성 테스트 케이스의 경우 +1. –
코드가 너무 명확하여 표준을 향해 (적어도 내 버전에서는) 컴파일러의 불완전한 지원을 의심하고 있습니다. 어떻게 확인할 수 있습니까? – cateof
참조 용 - MSVC 2010 SP1 (16.00.40219.01)은 일치 항목을 올바르게 컴파일하고 찾습니다. 사용중인 GCC의 버전을 지정하지 않았습니다. – DCoder