Yeah but I don't want to include \ I just want to use it as a escape sequence |
No you don't want the escape sequence, you want the actual \ character. Put in \\
Is there any way we can turn off these type of errors. |
No. In C/C++, if you want to have a string containing a \ character, it
must have \\ because a single \ starts an escape sequence.
Terminal != C++
perhaps I should clarify this further:
Strings that you put in quotes are not exact copies of the strings they represent. If they were, it would be impossible to represent some characters (like the " character, as previously mentioned). Therefore C/C++ compilers step through these strings and look for escape sequences to translate them into seperate characters.
For example '\n' is an escape sequence which represents a new line (ASCII code 0x0A). This is seperate from both the '\' character (ASCII code 0x5C) and 'n' character (0x6E).
When you put '\d' or '\.' in a string, the compiler looks at that and sees the \ so it starts an escape sequence, but then looks at the next characters and says "hey, this isn't a valid escape sequence!". This is what is giving you the compiler warning. And since the compiler couldn't step through the string properly, the string your sending to your regex lib is probably bad, which is causing the mismatching (giving you errors).