What's the best way to escape an arbitrary std::wstring for use inside a regular expression? For example, convert you owe me $ to you owe me \$?
My scenario: I want to use a std::tr1::wregex to search for a whole word. So I want to do something like:
std::wstring RegexEscape(const std::wstring& inp)
{
return ?????
}
bool ContainsWholeWord(const std::wstring& phrase, const std::wstring& word)
{
std::tr1::wregex regex(std::wstring(L"\\b") + RegexEscape(word) + L"\\b");
return std::tr1::regex_match(phrase, regex);
}