Boost logo

Boost Users :

Subject: [Boost-users] regex_replace and Unicode ( Cyrillic ) problem
From: valery O (egersheldster_at_[hidden])
Date: 2012-03-31 05:05:37


I have a string with 2 Cyrillic words ÎÏ×ÙÊ ÄÏÍ repeated 3 times.

I try to regex_replace each occurrance of these words.

For this I use std:: string format("$1 ËÒÁÓÎÙÊ $2")

and regex pattern ("(\\W+)\\s+(\\W+)"),

The result is only the last occurrence is replaced,the 2 preceding ones are

Where is my mistake?

My code:

#include <iostream>

#include <string>

#include "boost/regex.hpp"

using namespace std;

int main(int argc, const char** argv)


std::string str( "ÎÏ×ÙÊ ÄÏÍ, ÎÏ×ÙÊ ÄÏÍ ÎÏ×ÙÊ ÄÏÍ" );

 regex regx("(\\W+)\\s+(\\W+)");

   std::string format( "$1 ËÒÁÓÎÙÊ $2");

cout<<"regex_replace :"<<regex_replace( str, regx, format );

 return 0;


I use iMac Intel Core Duo, Mac OSX 10.6.8,

IDE - Xcode 3.2.6

Thank you.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at