views:

42

answers:

1

I want to put space between punctuations and other words in a sentence. But boost::regex_replace() replaces the punctuation with space, and I want to keep a punctuation in the sentence! for example in this code the output should be "Hello . hi , "

regex e1("[.,]");
std::basic_string<char> str = "Hello.hi,";
std::basic_string<char> fmt = " ";
cout<<regex_replace(str, e1, fmt)<<endl;

Can you help me?

+1  A: 
swestrup
and he can replace his std::basic_string<char> by just std::string
Nikko
Yes, I'd noticed that, but decided to concentrate on answering the question that was asked.
swestrup