+ sregex_iterator re_it(str.begin(), str.end(), *p_regexp, flags);
+ if (re_it == sregex_iterator())
+ return 0;
+ match_results<string::const_iterator> const & m = *re_it;
+
+ // Check braces on the segment that matched the entire regexp expression,
+ // plus the last subexpression, if a (.*?) was inserted in the constructor.
+ if (!braces_match(m[0].first, m[0].second, open_braces))
+ return 0;
+
+ // Check braces on segments that matched all (.*?) subexpressions,
+ // except the last "padding" one inserted by lyx.
+ for (size_t i = 1; i < m.size() - 1; ++i)
+ if (!braces_match(m[i].first, m[i].second))
+ return false;
+
+ // Exclude from the returned match length any length
+ // due to close wildcards added at end of regexp
+ if (close_wildcards == 0)
+ return m[0].second - m[0].first;
+
+ return m[m.size() - close_wildcards].first - m[0].first;
+ }
+
+ // else !use_regexp: but all code paths above return
+ LYXERR(Debug::FIND, "Searching in normal mode: par_as_string='"
+ << par_as_string << "', str='" << str << "'");
+ LYXERR(Debug::FIND, "Searching in normal mode: lead_as_string='"
+ << lead_as_string << "', par_as_string_nolead='"
+ << par_as_string_nolead << "'");
+
+ if (at_begin) {
+ LYXERR(Debug::FIND, "size=" << par_as_string.size()
+ << ", substr='" << str.substr(0, par_as_string.size()) << "'");
+ if (str.substr(0, par_as_string.size()) == par_as_string)
+ return par_as_string.size();