Я использую Boost.Regex (boost-1.42) для удаления первой строки многострочной строки (довольно большая строка, содержащая несколько строк, оканчивающихся на '\ n').
т.е. с помощью regex_replace сделать что-то похожее на s / (. *?) \ n //
string
foo::erase_first_line(const std::string & input) const
{
static const regex line_expression("(.*?)\n");
string empty_string;
return boost::regex_replace(input,
line_expression,
empty_string,
boost::format_first_only);
}
Этот код выдает следующее исключение:
"terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error> >'
what(): The complexity of matching the regular expression exceeded predefined bounds. Try refactoring the regular expression to make each choice made by the state machine unambiguous. This exception is thrown to prevent "eternal" matches that take an indefinite period time to locate."
Интересно / досадно, что этого не происходит в тестовых программах с одинаковыми тестовыми данными. Любые мысли о том, почему это может происходить и / или как это исправить?