Попытка разделить строку на подразделы с помощью std :: regex."(^([\s\S]+?)\s*(\W)\s*[\r\n]+A\.\s*((?:.+(?:[\r\n](?![B-D]\.))*)+)[\r\n]+B\.\s*((?:.+(?:[\r\n](?![CD]\.))*)+)[\r\n]+C\.\s*((?:.+(?:[\r\n](?!D\.))*)+)[\r\n]+D\.\s*([\s\S]+)$)"
< /code>
Большую часть времени он работает нормально, но в конкретном тексте он бросает исключение: < /p>
Unhandled exception:
Unhandled exception at 0x00007FF7C93FCF66 in Convert.exe: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x000000FE83A43F98).
< /code>
в xtr1common:
_ export_std _nodiscard contexpr bool is_constant_evalicated () noexcept {
return __builtin_is_constant_evalicated (); }
#endif // _has_cxx20 < /p>
< /blockquote>
строка: < /p>
The portfolio manager from your division thought it might be helpful to the project teams if she delivered a short presentation on the elements in her portfolio. A number of team members, after receiving the e- mail announcement for the presentation, come to you and ask if this meeting is worth their time. After all isn’t a portfolio just a big project? As a Senior Project manager your best response would be:
A. You’re right. The meeting probably would be a waste of your time
B. Not really. A portfolio is a group of related projects managed together to achieve synergies between the projects and establish common methods and procedures.
C. Not really. A portfolio can be a group of programs, projects, or sub-projects designed to help the organization meet specific business goals
D. Not really. A portfolio is a collection of documents, methods, and procedures that help us manage projects
< /code>
Значит ли это, что std -regex - это багги?#include
#include
#include
using std::string;
using std::regex;
using std::smatch;
int main()
{
string s = R"(The portfolio manager from your division thought it might be helpful to the project teams if she delivered a short presentation on the elements in her portfolio. A number of team members, after receiving the e- mail announcement for the presentation, come to you and ask if this meeting is worth their time. After all isn’t a portfolio just a big project? As a Senior Project manager your best response would be:
A. You’re right. The meeting probably would be a waste of your time
B. Not really. A portfolio is a group of related projects managed together to achieve synergies between the projects and establish common methods and procedures.
C. Not really. A portfolio can be a group of programs, projects, or sub-projects designed to help the organization meet specific business goals
D. Not really. A portfolio is a collection of documents, methods, and procedures that help us manage projects)";
string pattern = R"(^([\s\S]+?)\s*(\W)\s*[\r\n]+A\.\s*((?:.+(?:[\r\n](?![B-D]\.))*)+)[\r\n]+B\.\s*((?:.+(?:[\r\n](?![CD]\.))*)+)[\r\n]+C\.\s*((?:.+(?:[\r\n](?!D\.))*)+)[\r\n]+D\.\s*([\s\S]+)$)";
regex questionRegex(pattern, std::regex_constants::ECMAScript /* | std::regex_constants::collate */);
smatch question_match;
try {
if (regex_search(s, question_match, questionRegex)) {
std::cout
Подробнее здесь: https://stackoverflow.com/questions/795 ... ing-string