boost::regex…
- User
boost::regex regexBatch("^[\x20\x09]{0,}insert[\x20\x09]{0,}(into[\x20\x09]{0,}){0,1}(#[^\x20\x09\x28\x29]{1,})[\x20\x09]{0,}\x28([^\x29]{1,}){1,}\x29", boost::regbase::normal | boost::regbase::icase); to std::regex c++
- Assistant
In order to convert this boost::regex to std::regex in C++, you will need to make a few changes. First, you'll need to include the
<regex>header instead of the boost headers. Then, you'll replace the boost::regex object with a std::regex object and replace the boost-specific flag with the corresponding std::regex flag.Here's the converted code:
#include <regex> std::regex regexBatch("^[\\x20\\x09]{0,}insert[\\x20\\x09]{0,}(into[\\x20\\x09]{0,}){0,1}(#[^\\x20\\x09\\x28\\x29]{1,})[\\x20\\x09]{0,}\\x28([^\\x29]{1,}){1,}\\x29", std::regex_constants::ECMAScript | std::regex_constants::icase);Note that in C++11's
std::regex, you should usestd::regex_constants::ECMAScriptfor the normal behavior of regex, which is similar to boost::regbase::normal. Also,std::regex_constants::icasecorresponds to the case-insensitive flag, similar to boost::regbase::icase.