diff --git a/Userland/Utilities/expr.cpp b/Userland/Utilities/expr.cpp index d8371d5318..253adce1c9 100644 --- a/Userland/Utilities/expr.cpp +++ b/Userland/Utilities/expr.cpp @@ -441,14 +441,17 @@ private: void ensure_regex() const { - if (!m_compiled_regex) - m_compiled_regex = make>(m_pos_or_chars->string()); + if (!m_compiled_regex) { + m_compiled_regex = make>(m_pos_or_chars->string()); + if (m_compiled_regex->parser_result.error != regex::Error::NoError) + fail("Regex error: {}", regex::get_error_string(m_compiled_regex->parser_result.error)); + } } StringOperation m_op { StringOperation::Substring }; NonnullOwnPtr m_str; OwnPtr m_pos_or_chars, m_length; - mutable OwnPtr> m_compiled_regex; + mutable OwnPtr> m_compiled_regex; }; NonnullOwnPtr Expression::parse(Queue& args, Precedence prec)