Opened 4 years ago

#13634 new Bugs

regex duplicating literal part of replace string

Reported by: joseph@… Owned by: John Maddock
Milestone: To Be Determined Component: regex
Version: Boost 1.67.0 Severity: Problem
Keywords: Cc:

Description

The below code should result in 'moreless' but instead results in 'morelessless'

#include <iostream>
#include <string>
#include <boost/regex.hpp>

int main(int argc, char **argv)
{
  boost::regex::flag_type regex_flags = boost::regex_constants::normal;
  boost::regex_constants::match_flag_type match_flags = boost::regex_constants::match_default;
  boost::regex pattern("(.*)", regex_flags);
  std::string strResult;
  strResult = boost::regex_replace(std::string("more"), pattern, std::string("${1}less"), match_flags);
  std::cout << strResult << std::endl;
  char result;
  std::cin >> result;
  return 0;
}

Change History (0)

Note: See TracTickets for help on using tickets.