Nov 30, 2015 at 5:14pm UTC
hello,
I am looking to replace an "\b" by "\e[21m" in my text but i can't seem to figure out how to make it look for the character and not a backspace.
here is my code:
size_t bb = line.find("<\b>");
if(bb!=string::npos)
{line.replace(bb, string("<\b>").length(), "\e[21m");
cout << line << endl;
}
Nov 30, 2015 at 5:50pm UTC
You probably need to escape those escape characters: "<\\b>"
Last edited on Nov 30, 2015 at 5:50pm UTC
Dec 2, 2015 at 12:38pm UTC
> not necessary.
true, you may use a raw string literal R"(<\b>)"
but you completely missed the point in your example, as you are searching for the special character '\b'
and not for a backslash '\'
followed by a 'b'