aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc_src
diff options
context:
space:
mode:
authorGravatar Aaron Gyes <me@aaron.gy>2016-04-08 10:18:58 +0800
committerGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2016-04-08 10:49:29 +0800
commit790c7f80c7d0fa1c97380885201eb50a2abcce02 (patch)
tree71e525e03cb4dee3a0be8f18fd76ac35c0e2a7f9 /doc_src
parent155befe90e2e9e2ab022e81f5f3661bed3c8c9e9 (diff)
Implement an --invert/-v for string match, like grep -v.
Only lines that do not match the pattern are shown.
Diffstat (limited to 'doc_src')
-rw-r--r--doc_src/string.txt12
1 files changed, 10 insertions, 2 deletions
diff --git a/doc_src/string.txt b/doc_src/string.txt
index bae21dc9..58de93e4 100644
--- a/doc_src/string.txt
+++ b/doc_src/string.txt
@@ -12,7 +12,7 @@ string trim [(-l | --left)] [(-r | --right)] [(-c | --chars CHARS)]
[(-q | --quiet)] [STRING...]
string escape [(-n | --no-quoted)] [STRING...]
string match [(-a | --all)] [(-i | --ignore-case)] [(-r | --regex)]
- [(-n | --index)] [(-q | --quiet)] PATTERN [STRING...]
+ [(-n | --index)] [(-q | --quiet)] [(-v | --invert)] PATTERN [STRING...]
string replace [(-a | --all)] [(-i | --ignore-case)] [(-r | --regex)]
[(-q | --quiet)] PATTERN REPLACEMENT [STRING...]
\endfish
@@ -44,7 +44,7 @@ The following subcommands are available:
- `escape` escapes each STRING such that it can be passed back to `eval` to produce the original argument again. By default, all special characters are escaped, and quotes are used to simplify the output when possible. If `-n` or `--no-quote` is given, the simplifying quoted format is not used. Exit status: 0 if at least one string was escaped, or 1 otherwise.
-- `match` tests each STRING against PATTERN and prints matching substrings. Only the first match for each STRING is reported unless `-a` or `--all` is given, in which case all matches are reported. Matching can be made case-insensitive with `-i` or `--ignore-case`. If `-n` or `--index` is given, each match is reported as a 1-based start position and a length. By default, PATTERN is interpreted as a glob pattern matched against each entire STRING argument. If `-r` or `--regex` is given, PATTERN is interpreted as a Perl-compatible regular expression. For a regular expression containing capturing groups, multiple items will be reported for each match, one for the entire match and one for each capturing group. Exit status: 0 if at least one match was found, or 1 otherwise.
+- `match` tests each STRING against PATTERN and prints matching substrings. Only the first match for each STRING is reported unless `-a` or `--all` is given, in which case all matches are reported. Matching can be made case-insensitive with `-i` or `--ignore-case`. If `-n` or `--index` is given, each match is reported as a 1-based start position and a length. By default, PATTERN is interpreted as a glob pattern matched against each entire STRING argument. If `-r` or `--regex` is given, PATTERN is interpreted as a Perl-compatible regular expression. For a regular expression containing capturing groups, multiple items will be reported for each match, one for the entire match and one for each capturing group. If --invert or -v is used the selected lines will be only those which do not match the given glob pattern or regular expression. Exit status: 0 if at least one match was found, or 1 otherwise.
- `replace` is similar to `match` but replaces non-overlapping matching substrings with a replacement string and prints the result. By default, PATTERN is treated as a literal substring to be matched. If `-r` or `--regex` is given, PATTERN is interpreted as a Perl-compatible regular expression, and REPLACEMENT can contain C-style escape sequences like `\t` as well as references to capturing groups by number or name as `$n` or `${n}`. Exit status: 0 if at least one replacement was performed, or 1 otherwise.
@@ -120,6 +120,14 @@ The following subcommands are available:
>_ echo 'ok?' | string match '*\\?'
>_ <outp>ok?</outp>
+
+>_ string match -r -v "c.*[12]" {cat,dog}(seq 1 4)
+<outp>dog1</outp>
+<outp>dog2</outp>
+<outp>cat3</outp>
+<outp>dog3</outp>
+<outp>cat4</outp>
+<outp>dog4</outp>
\endfish
\subsection string-example-match-regex Match Regex Examples