From 8cd51227c61ddd40d94f38e4fb5022654382f0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teemu=20P=C3=A4tsi?= Date: Sat, 26 Apr 2025 18:22:22 +0300 Subject: [PATCH] expr: Fix regex anchor matching behavior with `REGEX_OPTION_SINGLELINE` The previously used `REGEX_OPTION_NONE` allowed anchors (^) and ($) to match across newlines. New anchor behaviors: - `^` matches the start of the entire string (`\A`) - `$` matches the end of the entire string (`\Z`) --- src/uu/expr/src/syntax_tree.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/expr/src/syntax_tree.rs b/src/uu/expr/src/syntax_tree.rs index ac418cafe..e6a5b3472 100644 --- a/src/uu/expr/src/syntax_tree.rs +++ b/src/uu/expr/src/syntax_tree.rs @@ -154,7 +154,7 @@ impl StringOp { let re_string = format!("{prefix}{right}"); let re = Regex::with_options( &re_string, - RegexOptions::REGEX_OPTION_NONE, + RegexOptions::REGEX_OPTION_SINGLELINE, Syntax::grep(), ) .map_err(|_| ExprError::InvalidRegexExpression)?;