Probably depends on which specificRegeximplementation you are using!
But, generally, characters that have a "special" meaning in Regex are escaped by prepending a \ character. Though keep in mind that the \ character already acts as an escape character C/C++ string literals!
For example, the following Regex matches any (non-empty) sequence of characters: .+
...because the . is a "wildcard" character in Regex.
At the same time, this Regex only matches a sequence of literal dot (.) characters: \.+
And, written as a C/C++ string literal, the above Regex then becomes: "\\.+"
...because, in a C/C++ string literal, the sequence \\ translates to a single \ character.
The use of raw string literals is correct, but I do recommend using a delimiter in regular expression strings — leaving it blank will bite you.
I personally prefer using “<>” for my raw literals; the likelihood of that conflicting with anything is low, making it easier for me to parse its utility. Plus it is really easy to view, IMHO.
For example, this arcane bit of RE:
R"<>((\S+)(\s+\1){4})<>"
I think it is pretty easy to find just the
((\S+)(\s+\1){4})
out of that; all you need to do is remember that the outer parentheses are also not part of the RE and you are golden:
(\S+)(\s+\1){4}
...which is:
• capture some non-whitespace sequence (the first parenthesized part),
• then exactly four more of the same sequence with leading whitespace
(the second parenthesized part and the count=4 requirement in curly braces).
This is, of course, my personal opinion. Take it as you wish.