Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Example of use of (S) flag
- X-seq: zsh-users 21102
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Example of use of (S) flag
- Date: Wed, 23 Dec 2015 21:01:57 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=5YLCOXcRRitCzZP0xGaDDnh3g64P1EJfJ+zwpKYJdwU=; b=ivqT6qFjRXfD70xCI7MbCo2jEe8UA8l3J6jqR8q5x1b+NXlKqmlrlVHUQvLgyG2xuA VIGGOsHKfjYsfWHe99yBtAurQrrG3DJ63pMJwFXtMCQ2QZVP+VnjmbeOdSvbL0FgHoNR EGum8jYEVMjAbHDiEBrSkmA1MhpiCQCJoxpQCYNE4r2umetmWvmfcW9GA0yidyLTbaN6 Ki2JyJW/Fqxp9PFjAUS8lmTPfX6XKOVFLrqIO4Vmvd02912bkRN5QG4EpD7YCdLmUm7l csQddlRtNiMHX83pGo2p6hw8g/WzFZSpQU3Nznams7rTv0HdNjwTsmPRRcJHMJRW1mEa PGeQ==
- In-reply-to: <20151223232519.GA9602@chaz.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVBLdXYQ_NNU9q=v9TcfiZjsYKfDt2h=ZBdfGCt6t81cuQ__14537.6145992943$1450895198$gmane$org@mail.gmail.com> <20151223232519.GA9602@chaz.gmail.com>
On Dec 23, 11:25pm, Stephane Chazelas wrote:
} Subject: Re: Example of use of (S) flag
}
} 2015-12-23 19:25:05 +0100, Sebastian Gniazdowski:
} > Hello,
} > completion says that (S) is "search substrings in #, %, /
} > expressions". Can someone provide example of (S) influence? Thanks
} [...]
}
} $ a=ababa
} $ echo ${(S)a#b}
} aaba
} $ echo ${(S)a%b}
} abaa
Note also that ${(S)var:#pat} is not useful; pat must still match the
entire value of $var (or an element of $var in the array case) for the
element to be matched/removed.
Further note that (MS) is sort of a dumbed-down form of backreferences,
returning something similar to the value of $MATCH in an extendeglob
pattern that uses (#m) (except extendedglob is not needed). E.g.:
% a=abcba
% echo ${(MS)a#b?}
bc
% echo ${(MS)a%b?}
ba
Here are some examples of the use with ${var/pat/repl}:
torch% echo ${a/b*/x}
ax
torch% echo ${(S)a/b*/x}
axcba
torch% echo ${(S)a//b*/x}
axcxa
Messages sorted by:
Reverse Date,
Date,
Thread,
Author