I am trying to replace every non-absolute character in a string with " " using Boost:
std::string sanitize(std::string &str) { boost::regex re; re.imbue(std::locale("fr_FR.UTF-8")); re.assign("[^[:alpha:]]"); str = boost::regex_replace(str, re, " "); return str; } int main () { std::string test = "(ça) /.2424,@ va très bien ?"; cout << sanitize(test) << endl; return 0; }
The result is a va tr s bien , but I would like to get ça va très bien .
What am I missing?
source share