Regex to find and replace "8" and similar at the end of strings [duplicate]

  c++, regex, regexp-replace

Trying to do a regex_replace to convert "C:somethingwin.exe" to "C:somethingwin.exe" :

std::wstring path= L"C:somethingwin.exe";
std::wregex pathRegex(L"+d+$");
std::wstring sPath= std::regex_replace(path, pathRegex, std::wstring());

The above doesnt work. I get the same string.

Other regexes I tried:

"{1}d+$"   => unhandled regex_error

".{1}d+$"   => works but not quite as narrow as hoped

"\d+$"     => doesnt work

Any suggestions ?

Thanks.

Source: Windows Questions C++

LEAVE A COMMENT