// regex_replace example
#include <iostream>
#include <string>
#include <regex>
#include <iterator>
int main ()
{
std::string INPUT = "Replace_All_Characters_With_Anything";
std::string OUTEXP = "0";
std::regex expression("[A-Za-z]", std::regex_constants::icase);
std::cout << std::regex_replace(INPUT, expression, OUTEXP);
return 0;
}
This works here: http://cpp.sh/6gb5a This works here: https://regexr.com/5bt9d
The problem seems to be down to using icase flag or not. A in All, the C in Characters, the W in With, etc. does not get replaced because of the underscore existing. The bug seems to be that using [] to match things only works if said character does not come after a non match.
There does seem to be a quick fix for this, if brackets are followed by a {1}, then it works.
example: [A-Za-z]{1}
Compiler: Microsoft Visual Studio Community 2019 / Version 16.7.3 / c++17
Also tested in c++14, same bad behavior

