diff --git a/Libraries/LibRegex/RegexParser.cpp b/Libraries/LibRegex/RegexParser.cpp index f8685777252..f648c180f3b 100644 --- a/Libraries/LibRegex/RegexParser.cpp +++ b/Libraries/LibRegex/RegexParser.cpp @@ -120,10 +120,9 @@ ALWAYS_INLINE Optional Parser::consume_escaped_code_point(bool unicode) ALWAYS_INLINE bool Parser::try_skip(StringView str) { - if (str.starts_with(m_parser_state.current_token.value())) - str = str.substring_view(m_parser_state.current_token.value().length(), str.length() - m_parser_state.current_token.value().length()); - else + if (!str.starts_with(m_parser_state.current_token.value())) return false; + str = str.substring_view(m_parser_state.current_token.value().length(), str.length() - m_parser_state.current_token.value().length()); size_t potentially_go_back { 0 }; for (auto ch : str) {