bool has_no_unescaped_special_chars( const std::string& pat ) {
// a regex special character either preceded by any character other than a \
// or is at the beginning of the string
staticconst std::regex unescaped_special_char_re( R"((?:[^\\]|^)[\^$.*+|?()[\]{}[])" ) ;
return !std::regex_search( pat, unescaped_special_char_re ) ;
}
Yes, put that & on pat parameter for sure. Good catch. JLBorges fixed it as well.
I know it may not matter. But you have a do-nothing function there. Regex_match does all the work. is-simple string --- does nothing at best, at worst it injects some overhead. If you are short on time and performance, maybe skip that? Or at least see if it is making any difference when you do a billionty of them?
I don't know the regex stuff well performance side. Is search faster than match? Seems like it would be...