From 7673781751a5d1e68d0d46b99d8da08492249f24 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 29 Sep 2017 10:39:59 +0800 Subject: [PATCH] Regex: use \A \z for subject start/end This is the most common syntax in various regex variants. --- src/regex_impl.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/regex_impl.cc b/src/regex_impl.cc index 26b0a738..057dbc11 100644 --- a/src/regex_impl.cc +++ b/src/regex_impl.cc @@ -125,8 +125,6 @@ private: AstNodePtr res = new_node(op); while (auto node = term()) res->children.push_back(std::move(node)); - if (res->children.empty()) - parse_error("empty alternative"); return res; } @@ -158,8 +156,8 @@ private: { case 'b': m_pos += 2; return new_node(ParsedRegex::WordBoundary); case 'B': m_pos += 2; return new_node(ParsedRegex::NotWordBoundary); - case '`': m_pos += 2; return new_node(ParsedRegex::SubjectBegin); - case '\'': m_pos += 2; return new_node(ParsedRegex::SubjectEnd); + case 'A': m_pos += 2; return new_node(ParsedRegex::SubjectBegin); + case 'z': m_pos += 2; return new_node(ParsedRegex::SubjectEnd); case 'K': m_pos += 2; return new_node(ParsedRegex::ResetStart); } break;