I want to print a value in boost::u32regex & reg
using std::cout
.
For boost::regex & reg
, I can print reg.str()
but not able to use str()
to boost::u32regex
.
Can anyone please tell me ?
I want to print a value in boost::u32regex & reg
using std::cout
.
For boost::regex & reg
, I can print reg.str()
but not able to use str()
to boost::u32regex
.
Can anyone please tell me ?
It seems that the type used behind boost::u32regex
is not compatible with cout
. It seems they are using Uchar32
from the ICU
library.
You can print your regex value by using iterators :
#include <boost/regex.hpp>
#include <boost/regex/icu.hpp>
#include <unicode/ustream.h>
void PrintRegex32( const boost::u32regex& r )
{
boost::u32regex::iterator it = r.begin();
boost::u32regex::iterator ite = r.end();
for ( ; it != ite; ++it )
{
std::cout << UnicodeString(*it) << std::endl;
}
}
This is working for me. It is not as easy as printing a boost::regex
value but it works. I suggest you to create a function to do so, like in the example.
EDIT :
You can try the code :
boost::u32regex r = boost::make_u32regex("(?:\\A|.*\\\)([^\\\]+)");
PrintRegex32( r );
I can print
reg.str()
Just for the information, boost::basic_regex
has an operator<<
overload who are doing exactly the same thing so :
// reg is a boost::regex
std::cout << reg.str() << std::endl;
is the same thing as
// reg is a boost::regex
std::cout << reg << std::endl;