Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: substitution groups and patterns i replace string (Emacs' \\1 etc.)
- X-seq: zsh-users 21343
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: substitution groups and patterns i replace string (Emacs' \\1 etc.)
- Date: Thu, 03 Mar 2016 09:41:40 +0000
- In-reply-to: <87k2lk2ws9.fsf@debian.uxu>
- 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
- Organization: Samsung Cambridge Solution Centre
- References: <87k2lk2ws9.fsf@debian.uxu>
On Thu, 3 Mar 2016 02:08:22 +0100
Emanuel Berg <embe8573@xxxxxxxxxxxxx> wrote:
> When I do substitution, can I do groups and patterns
> like in Emacs with \\1, \\2 to reference the
> particular matches, and thus construct the replace
> string out of them any way I like?
You do it with $match, and if you need to refer to positions in the
original string, $mbegin and $mend. See the description of the (#b)
pattern in the zshexpn manual page.
local -a match mbegin mend
if [[ $url = (#b)http://(*) ]]; then
print $match[1]
fi
Works with other forms of pattern matching.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author