c++ - How to print value in boost::u32regex & reg -
i want print value in boost::u32regex & reg
using std::cout
.
for boost::regex & reg
, can print reg.str()
not able use str()
boost::u32regex
.
can please tell me ?
it seems type used behind boost::u32regex
not compatible cout
. seems using uchar32
icu
library.
you can print regex value using iterators :
#include <boost/regex.hpp> #include <boost/regex/icu.hpp> #include <unicode/ustream.h> void printregex32( const boost::u32regex& r ) { boost::u32regex::iterator = r.begin(); boost::u32regex::iterator ite = r.end(); ( ; != ite; ++it ) { std::cout << unicodestring(*it) << std::endl; } }
this working me. not easy printing boost::regex
value works. suggest create function so, in example.
edit :
you can try code :
boost::u32regex r = boost::make_u32regex("(?:\\a|.*\\\)([^\\\]+)"); printregex32( r );
i can print
reg.str()
just information, boost::basic_regex
has operator<<
overload doing same thing :
// reg boost::regex std::cout << reg.str() << std::endl;
is same thing as
// reg boost::regex std::cout << reg << std::endl;
Comments
Post a Comment