我正在使用 boost xpressive regex_replace 。替换后,我在字符串末尾得到垃圾字符
std::wstring wEsc(L"fxSSyrpng");
std::wstring wReplaceByText(L"tiff");
std::wstring searchText(L"fx");
wsregex regExp;
try
{
regExp = wsregex::compile( searchText );
}
catch ( regex_error &/*error*/ )
{
throw ;
}
catch (...)
{
throw ;
}
std::wstring strOut;
strOut.reserve( wEsc.length() + wReplaceByText.length() );
std::wstring::iterator it = strOut.begin();
boost::xpressive::regex_replace( it, wEsc.begin() , wEsc.end(), regExp,
wReplaceByText, regex_constants::match_not_null );