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."
興味深い/厄介なことに、これは同じテスト データを使用したテスト プログラムでは発生しないようです。なぜこれが起こっているのか、および/またはそれを修正する方法について何か考えはありますか?