CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    Mar 2011

    Performing RegEx on open file

    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 -
    [for ( std::vector<TCHAR>::iterator It = buffer.begin();It != buffer.end(); It++ )
    since I've already copied the file into the buffer, but how do I search the buffer?

    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::istreambuf_iterator<TCHAR>( in ),
    		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);
    					SendMessage (textArea, EM_SETSEL, 0, MAKELONG (ndx, ndx));
    					SendMessage (textArea, EM_REPLACESEL, 0, (LPARAM) (TextAreaBuffer));
    Last edited by drwbns; January 11th, 2013 at 11:45 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

By using this site, you agree to the Privacy Policy