I'm just starting out with boost and c++ and I'm struggling to understand the behaviour of boost's regular expression engine when it comes to matching whitespace. If I use the code:
boost::regex rx(" ");
cout << regex_search(" ", rx);
to match spaces, then everything works as expected and the regex_search returns true. However, if I try replacing the regular expression with "\s" to match all whitespace characters, I never get a match, and the following code always outputs false:
boost::regex rx("\\s");
cout << regex_search(" ", rx);
What am I missing here?
As requested, here's my complete test case:
#include <boost/regex.hpp>
#include <iostream>
using namespace std;
int main()
{
boost::regex rx("\\s", boost::regex::icase);
cout << regex_search(" ", rx);
}