jeudi 29 octobre 2015

Suffix ($´) in c++ regex_replace doesn't work

According to c++ regex_replace specification, is supposed to specify the suffix of the match. But it doesn't work:

#include <iostream>
#include <string>
#include <regex>
#include <iterator>

int main ()
{
  std::string s ("there is a subsequence in the string\n");
  std::regex e ("\\b(a )(subsequence)(.*)");
  // with flags:
  std::cout << std::regex_replace (s,e,"$´1digit$03",std::regex_constants::format_default);
  std::cout << std::endl;

  return 0;
}

Output:

there is $´1digit in the string

Instead of the suffix, it prints literally. How can I make this work?

N.B: I couldn't find this ´ character on my keyboard (copied from the regex_replace specification page from cplusplus.com)

Aucun commentaire:

Enregistrer un commentaire