0

I am using boost 1.54 library in my program. My task is to expand some patterns in a string.

One such instance is if a closing brace } is found in the string replace it with >

I had written the following regex in my code.

boost::wregex rightbrace(L"\}"); // replace this by >

strText = boost::regex_replace(strText, rightbrace, L">");

My code is compiling fine. But my program crashes when it encounters the first statement it crashes with the following exception

Unhandled exception at 0x7599c41f in Compress.exe: Microsoft C++ exception: boost::exception_detail::clone_impl > @ 0x0018fa54

Since } is a special symbol I have escaped it with \ symbol.

Can anyone tell me what is the issue here?

Pierre Fourgeaud
  • 14,290
  • 1
  • 38
  • 62
Ravi Chandra
  • 677
  • 12
  • 24

1 Answers1

1

You've escaped the } for boost, but you need to escape the \ escape char for the compiler as well.

boost::wregex rightbrace(L"\\}");
Jonathan Potter
  • 36,172
  • 4
  • 64
  • 79