C++ 使用boost正则表达式匹配二进制数据
boost regex能够匹配给定二进制输入中的二进制数据吗? 例:C++ 使用boost正则表达式匹配二进制数据,c++,boost-regex,C++,Boost Regex,boost regex能够匹配给定二进制输入中的二进制数据吗? 例: 以二进制形式输入: 0x01 0x02 0x03 0x04 0x05 0x01 0x02 0x03 0x04 0x08 要匹配的二进制表达式: 0x01 0x02 0x03 0x04 在这种情况下,应匹配2个实例 非常感谢 是的,boost::regex支持二进制 你的问题对我来说不够清楚。那么如果这个答案不是什么 你在找,告诉我我会删除它 regexboost库比C++强大得多,如屏幕截图所示: 同样,当C++可以做到这
以二进制形式输入:
0x01 0x02 0x03 0x04 0x05 0x01 0x02 0x03 0x04 0x08
要匹配的二进制表达式:0x01 0x02 0x03 0x04
在这种情况下,应匹配2个实例
非常感谢 是的,boost::regex支持二进制 你的问题对我来说不够清楚。那么如果这个答案不是什么 你在找,告诉我我会删除它
regex
boost库比C++
强大得多,如屏幕截图所示:
同样,当C++可以做到这一点时,当然Boost也可以做到这一点。std::regex::iterator
std::string binary( "0x01 0x02 0x03 0x04 0x05 0x01 0x02 0x03 0x04 0x08" );
std::basic_regex< char > regex( "0x01 0x02 0x03 0x04" );
// or
// std::basic_regex< char > regex( "0x01.+?4" );
std::regex_iterator< std::string::iterator > last;
std::regex_iterator< std::string::iterator > begin( binary.begin(), binary.end(), regex );
while( begin != last ){
std::cout << begin->str() << '\n';
++begin;
}
std::string binary( "0x01 0x02 0x03 0x04 0x05 0x01 0x02 0x03 0x04 0x08" );
std::basic_regex< char > regex( " 0x0[58] ?" );
std::regex_token_iterator< std::string::iterator > last;
std::regex_token_iterator< std::string::iterator > begin( binary.begin(), binary.end(), regex, -1 );
while( begin != last ){
std::cout << *begin << '\n';
++begin;
}
或std::regex\u令牌::迭代器
std::string binary( "0x01 0x02 0x03 0x04 0x05 0x01 0x02 0x03 0x04 0x08" );
std::basic_regex< char > regex( "0x01 0x02 0x03 0x04" );
// or
// std::basic_regex< char > regex( "0x01.+?4" );
std::regex_iterator< std::string::iterator > last;
std::regex_iterator< std::string::iterator > begin( binary.begin(), binary.end(), regex );
while( begin != last ){
std::cout << begin->str() << '\n';
++begin;
}
std::string binary( "0x01 0x02 0x03 0x04 0x05 0x01 0x02 0x03 0x04 0x08" );
std::basic_regex< char > regex( " 0x0[58] ?" );
std::regex_token_iterator< std::string::iterator > last;
std::regex_token_iterator< std::string::iterator > begin( binary.begin(), binary.end(), regex, -1 );
while( begin != last ){
std::cout << *begin << '\n';
++begin;
}
std::字符串二进制(“0x01 0x02 0x03 0x04 0x05 0x01 0x02 0x03 0x04 0x08”);
std::basic_regexregex(“0x0[58]?”);
std::regex_token_迭代器last;
std::regex_token_迭代器begin(binary.begin(),binary.end(),regex,-1);
while(开始!=最后){
std::不能持久;
boost::regex_token_iteratorbegin(binary.begin(),binary.end(),regex,-1);
while(开始!=最后){
std::请看和