From 8b7597913e588a25ea39c5c49af5f74fbac084d7 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 26 Jun 2024 22:46:50 -0500 Subject: [PATCH] Add tests for `string match/replace --max-matches` --- tests/checks/string.fish | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/checks/string.fish b/tests/checks/string.fish index 2d5a08a6c..2519c68c3 100644 --- a/tests/checks/string.fish +++ b/tests/checks/string.fish @@ -1148,3 +1148,17 @@ string shorten abc \aabc ab abcdef | string escape # CHECK: \cga… # CHECK: ab # CHECK: a… + +printf "dog\ncat\nbat\ngnat\n" | string match -m2 "*at" +# CHECK: cat +# CHECK: bat + +printf "dog\ncat\nbat\nhog\n" | string match -rvm1 'at$' +# CHECK: dog + +printf "dog\ncat\nbat\n" | string replace -rf --max-matches 1 'at$' 'aught' +# CHECK: caught + +printf "dog\ncat\nbat\n" | string replace -r --max-matches 1 '^c' 'h' +# CHECK: dog +# CHECK: hat