Auto Escaping C++ Strings

Just a few weeks after celebrating C++’s  raw strings.  I found myself writing  regular expressions  in Visual Studio 2012. I was disappointed to find out VS 2012  it did not support raw strings.     It’s streaking just how half-baked VS 2012  is.  I think it safe the assume Microsoft Visual Studio’s marking team insisted  on sticking to a 2-year product release cycle while the technical team protested they need more time to implement the then new C++ 11 standard.  The compromise  was a product with only some of the exciting  new  C++  features in place.  The rest had to wait for VS 2013/2015.   As it turned out one of the casualties were raw strings.

Regex are difficult to read on their on,  writing and reading long escaped regex is a form of torture.   Fortunately the escaping and unescaping  parts follow  simple rules can be done automatically.  provides tools to escape and unescape a C++ string:


The example above escapes a regex matching a positive float enclosed by double quotes:

“\d*\.?\d+”  ->   “\\\d*\\.?\\d+\”


When forced to escape C++ string manually, it’s best to leave this daunting task to a computer  program which will do a faster, better job with less mistake.

Or, be more vocal about upgrading to a newer compiler.

Leave a Reply

Your email address will not be published. Required fields are marked *