mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-22 01:51:14 -03:00
string: Add "--groups-only" to match
This adds a simple way of picking bits from a string that might be a bit nicer than having to resort to a full `replace`. Fixes #6056
This commit is contained in:
@@ -8,9 +8,9 @@ Synopsis
|
||||
|
||||
::
|
||||
|
||||
string match [(-a | --all)] [(-e | --entire)] [(-i | --ignore-case)] [(-r | --regex)] [(-n | --index)] [(-q | --quiet)] [(-v | --invert)] PATTERN [STRING...]
|
||||
string match [(-a | --all)] [(-e | --entire)] [(-i | --ignore-case)] [(-g | --groups-only)] [(-r | --regex)] [(-n | --index)] [(-q | --quiet)] [(-v | --invert)] PATTERN [STRING...]
|
||||
|
||||
.. END SYNOPSIS
|
||||
. END SYNOPSIS
|
||||
|
||||
Description
|
||||
-----------
|
||||
@@ -23,6 +23,8 @@ If you specify the ``-e`` or ``--entire`` then each matching string is printed i
|
||||
|
||||
Matching can be made case-insensitive with ``--ignore-case`` or ``-i``.
|
||||
|
||||
If ``--groups-only`` or ``-g`` is given, only the capturing groups will be reported - meaning the full match will be skipped. This is incompatible with ``--entire`` and ``--invert``, and requires ``--regex``. It is useful as a simple cutting tool instead of ``string replace``, so you can simply choose "this part" of a string.
|
||||
|
||||
If ``--index`` or ``-n`` 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. A glob pattern is only considered a valid match if it matches the entire STRING.
|
||||
|
||||
If ``--regex`` or ``-r`` is given, PATTERN is interpreted as a Perl-compatible regular expression, which does not have to match the entire STRING. 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. With this, only the matching part of the STRING will be reported, unless ``--entire`` is given.
|
||||
|
||||
Reference in New Issue
Block a user