how to use boost::regex to match all kind of whitespace include the unicode ones?

Viewed 71

It seems the \s only match ASCII whitespace.

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

int main()
{
    std::string x{"  ABC"};
    std::cout << x << "\n";
    boost::regex regex{"\\s"};
    for (auto i : x)
    {
        std::cout << static_cast<unsigned>(i) << ",";
    }
    std::cout << "\n";
    auto y = boost::regex_replace(x, regex, "");
    std::cout << y << "\n";
    for (auto i : y)
    {
        std::cout << static_cast<unsigned>(i) << ",";
    }
    std::cout << "\n";
    return 0;
}

The output is:

  ABC
4294967234,4294967200,32,65,66,67,
 ABC
4294967234,4294967200,65,66,67,

Is there anyway to solve this problem inside boost?

0 Answers
Related