// BoostRegexTest.cpp : Defines the entry point for the console application. // //#define BOOST_REGEX_NON_RECURSIVE #include "stdafx.h" #include #include #include int _tmain(int argc, _TCHAR* argv[]) { // Hier mache ich jetzt den Boost Regex Test std::string a_OutputString; std::string a_InputString = ""; std::string a_RegExString = ".*?\r\n(version .*?\r\n)"; std::ifstream fs("Session.txt"); std::string tmp; while (!fs.eof()) { getline(fs,tmp); a_InputString += tmp + "\r\n"; } fs.close(); bool a_IsIgnoreCase = true; bool a_IsMatchNotDotNewline = false; bool a_IsMatchSingleLine = false; bool a_IsFormatAll = true; bool a_IsFormatNoCopy = true; if( !a_InputString.empty() && !a_RegExString.empty() ) { { boost::regex::flag_type a_RegExFlags = 0; boost::regex_constants::match_flag_type a_RegExMatchFlags = boost::regex_constants::format_default; if( a_IsIgnoreCase ) a_RegExFlags |= boost::regex::icase; boost::regex a_Expression( a_RegExString, a_RegExFlags ); { if( a_IsMatchNotDotNewline ) a_RegExMatchFlags |= boost::match_not_dot_newline; if( a_IsMatchSingleLine ) a_RegExMatchFlags |= boost::match_single_line; boost::sregex_iterator a_RegCheckIterator; boost::sregex_iterator a_RegIterator( a_InputString.begin(), a_InputString.end(), a_Expression, a_RegExMatchFlags ); a_OutputString.reserve( a_InputString.length() ); while( a_RegIterator != a_RegCheckIterator ) { for ( size_t i = 1; i < (*a_RegIterator).size(); i++ ) { a_OutputString += (*a_RegIterator)[i].str().c_str(); } a_RegIterator++; } } } } return 0; }