Browse - Programming Tips - How should I quote a regular expression in C++

Date: 2018nov16
Language: C++

Q.  How should I quote a regular expression in C++

A.  Use raw strings!
They have been in the language since C++11.
In a raw string, escape characters are not processed.
For example:

const char *regex = R"[\r\n]+";
Or multiline source code for an embedded language:
const char *code = R" line one line two ";
You can use another delimiter, eg:
const char *saying = R|He said "hello"|;