Skip to content

Commit

Permalink
Add tests for string match/replace --max-matches
Browse files Browse the repository at this point in the history
  • Loading branch information
mqudsi committed Jun 27, 2024
1 parent 86701aa commit 267c348
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/checks/string.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 267c348

Please sign in to comment.