c++ - Why doesn't boost regex '.{2}' match '??' -


i'm trying match chunks if interesting data within data stream.

there should leading < 4 alphanumeric characters, 2 characters of checksum (or ?? if no shecksum specified) , trailing >.

if last 2 characters alphanumeric, following code works expected. if they're ?? though fails.

// set pre-populated data buffer example std::string haystack = "fli<data??>bble";  // set regex static const boost::regex e("<\\w{4}.{2}>"); std::string::const_iterator start, end; start = haystack.begin(); end = haystack.end(); boost::match_flag_type flags = boost::match_default;  // try , find of interest in buffer boost::match_results<std::string::const_iterator> what; bool succeeded = regex_search(start, end, what, e, flags); // <-- returns false 

i've not spotted in the documentation suggests should case (all null , newline should match aiui).

so have missed?

because ??> trigraph, converted }, code equivalent to:

// set pre-populated data buffer example std::string haystack = "fli<data}bble";  // set regex static const boost::regex e("<\\w{4}.{2}>"); std::string::const_iterator start, end; start = haystack.begin(); end = haystack.end(); boost::match_flag_type flags = boost::match_default;  // try , find of interest in buffer boost::match_results<std::string::const_iterator> what; bool succeeded = regex_search(start, end, what, e, flags); // <-- returns false 

you can change this:

std::string haystack = "fli<data?" "?>bble"; 

demo (note: use std::regex more or less same)

note: trigraph deprecated c++11, (likely) removed c++17


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -