Hi, like the title says, I'm trying to open a file and perform a regex on it, then print the matches, but I'm not sure if I have it right. I think I need to remove the line -
since I've already copied the file into the buffer, but how do I search the buffer?Code:[for ( std::vector<TCHAR>::iterator It = buffer.begin();It != buffer.end(); It++ )
Code:std::ifstream in(TempFullPath, std::ios::in|std::ios::binary); if( in.fail() ) { std::cout << "File does not exist or could not open file"; } std::vector<TCHAR> buffer; std::copy( std::istreambuf_iterator<TCHAR>( in ), std::istreambuf_iterator<TCHAR>(), std::back_inserter( buffer ) ); for ( std::vector<TCHAR>::iterator It = buffer.begin();It != buffer.end(); It++ ) { sbuf = (*It); if( boost::regex_search(sbuf , matches, re ) ) { std::string value( matches[1].first, matches[1].second ); StringCchCat(TextAreaBuffer, MAX_PATH, value.c_str()); StringCchCat(TextAreaBuffer, MAX_PATH, TEXT("\r\n")); int ndx = GetWindowTextLength (textArea); SetFocus (textArea); #ifdef WIN32 SendMessage (textArea, EM_SETSEL, (WPARAM)ndx, (LPARAM)ndx); #else SendMessage (textArea, EM_SETSEL, 0, MAKELONG (ndx, ndx)); #endif SendMessage (textArea, EM_REPLACESEL, 0, (LPARAM) (TextAreaBuffer)); } }




Reply With Quote