Reputation: 249
I want to replace a \
in a string with \\\\
:
wsmatch Matches;
wstring String = L"\\";
regex_match( String, Matches, wregex( L"(\\\\)" ) );
if( Matches.size() > 0 ){
regex_replace( String, wregex( L"(\\\\)" ), L"x" );
wcout << L"Replaced in: " << String << endl;
}
It results in the following output:
Replaced in: \
It seems like a bug in VS13 or am I missing something?
Upvotes: 2
Views: 193
Reputation: 627087
Strings are immutable, use
String = regex_replace( String, wregex( L"(\\\\)" ), L"x" );
Upvotes: 1