1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

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`)
This commit is contained in:
Teemu Pätsi 2025-04-26 18:22:22 +03:00
parent 606c0c1f57
commit 8cd51227c6
No known key found for this signature in database

View file

@ -154,7 +154,7 @@ impl StringOp {
let re_string = format!("{prefix}{right}"); let re_string = format!("{prefix}{right}");
let re = Regex::with_options( let re = Regex::with_options(
&re_string, &re_string,
RegexOptions::REGEX_OPTION_NONE, RegexOptions::REGEX_OPTION_SINGLELINE,
Syntax::grep(), Syntax::grep(),
) )
.map_err(|_| ExprError::InvalidRegexExpression)?; .map_err(|_| ExprError::InvalidRegexExpression)?;