boost::regex_replace() replaces only first occurrence, why?
Posted
by Vincenzo
on Stack Overflow
See other posts from Stack Overflow
or by Vincenzo
Published on 2010-05-17T09:56:58Z
Indexed on
2010/05/17
10:00 UTC
Read the original article
Hit count: 214
My code:
#include <string>
#include <boost/algorithm/string/regex.hpp>
std::cout << boost::algorithm::replace_regex_copy(
"{x}{y}", // source string
boost::regex("\\{.*?\\}"), // what to find
std::string("{...}") // what to replace to
);
This is what I see:
{…}{y}
Thus, only the first occurrence replaced. Why? How to solve it?
© Stack Overflow or respective owner