When there are many slashes in a string (such as a regular expression), in order to facilitate writing and make no mistakes, you can use the original string literal constant.
1. The original string literal constant of std::string
#define debug qDebug()<<
#define cppdebug std::cout <<
int main(int argc, char *argv[])
{
std::string s = R"(asdfghjkl\n\t\y\z6666\\\\\)";
cppdebug "cppString " << s;
}
The form of R "(xxx)" represents the character string "xxx" without escaping.
When there is a newline in the character:
When you want to include parentheses in a string, add three asterisks before and after:
2. The original string literal constant in QString
QString's original string literal constant is not the same as std::string
As shown above, "\" has been added with a "\"
As shown in the figure above, the line break is to add a "\n" and a space, unlike std::string which has an actual line break.
The brackets in the string are consistent with std::string: