Hi All
I having an issue in using Boost regex with a MFC CString. The regex is very simple: it must check if the string ends with the name of a dll I am looking for. In the code below the CString Path DOES contain the dll I am looking for, but I don't know why the regex is failing. Uisng ReleaseBuffer increases the buffer size so the Length of Path is set to MAX_PATH. Do you know why is not correct? I did a lot of attempts but always failing.
#include <boost/regex/mfc.hpp>
const CString ValuesDLLName = _T("MyDll.dll");
boost::tregex EndsWithRegex( _T(".+MyDll.dll\s*$") );
//boost::tregex EndsWithRegex1( _T("^.+Values\.dll\\s*$") ); // not working
//boost::tregex EndsWithRegex2( _T("^.+Values\.dll\s*$") ); // not working
//boost::tregex EndsWithRegex3( _T("^.+Values.dll\s*$") ); // not working
//boost::tregex EndsWithRegex4( _T("^.+Values.dll\\s*$") ); // not working
//boost::tregex EndsWithRegex5( _T("^.+Values\.dll\\s*$"),boost::regex::perl ); // not working
//boost::tregex EndsWithRegex6( _T("^.+Values\.dll\s*$"),boost::regex::perl ); // not working
//boost::tregex EndsWithRegex7( _T("^.+Values.dll\s*$"),boost::regex::perl ); // not working
//boost::tregex EndsWithRegex8( _T("^.+Values.dll\\s*$") ,boost::regex::perl); // not working
CString Path;
boost::tmatch What;
_tsearchenv(ValuesDLLName, _T("PATH"), Path.GetBufferSetLength(260));
Path.ReleaseBuffer(260);
bool endsWithDllName = boost::regex_search( Path, What, EndsWithRegex );