I\'m just getting my head around regular expressions, and I\'m using the Boost Regex library.
I have a need to use a regex that includes a specific URL, and it choke
Using code from Dav (+ a fix from comments), I created ASCII/Unicode function regex_escape():
std::wstring regex_escape(const std::wstring& string_to_escape) {
static const boost::wregex re_boostRegexEscape( _T("[.^$|()\\[\\]{}*+?\\\\]") );
const std::wstring rep( _T("\\\\&") );
std::wstring result = regex_replace(string_to_escape, re_boostRegexEscape, rep, boost::match_default | boost::format_sed);
return result;
}
For ASCII version, use std::string/boost::regex instead of std::wstring/boost::wregex.