First time I tried using regular expressions in C++, and I\'m a little confused about escape sequences. I\'m simply trying to match a dot at the beginning of a string. For that
The compiler generates a warning because not every escape sequence has a meaning in C++. The list of valid escape sequences can be found here.
However, regex expects you to escape '.' in order to literally match a '.' character instead of anything. To escape '.' in a regex pattern, you must add a single '\' character before it. But since a single '\' means an escape in c++, you need to put two backslashes: "\\". Therefore, the correct pattern is "^\\.".