Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
End Index number not what I expected
- X-seq: zsh-users 22159
- From: Jim <linux.tech.guy@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: End Index number not what I expected
- Date: Tue, 6 Dec 2016 11:09:39 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:from:date:message-id:subject:to; bh=S7PvorvgYs5teBNkzS7cWFEyNFn/VFVD6ict4QBtj6c=; b=bZhWhvcqvMV1T0B+/5wqYMygEJkiQNvF6pBuefQsfc6jQiprk41iTbAlXK/eltylg7 NuYDzWaQE2wpsCWQRe7hOyMmpPb/6/TorMVfZ/Ua3y1GNGLBB8dzxIOK+/pDJuletYA0 x8UnSk0mF6oM4yYwApKGjLKftJEtgeNItmRk+pCZHAKewZWUicM3/17wtn0X1+ELLOC6 nRx+gJs0hRhc8Q+o+wdlBz4uWAniKX/HON/HJJCaK5js9kTLCooj559AtlelQqqFqr8w JenVtoXg+v1HchDjBdA23KU5F7ir33oqwyqmH5NL7xdQC9DrHr/rWMtPwGjORviZgxbp C3Tw==
- 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
- Reply-to: linuxtechguy@xxxxxxxxx
Hello List,
zsh version: 5.2
So far, searches on the web have not returned a satisfactory
answer. If I missed the answer, shame on me and sorry for
wasting you time.
The script I'm working on globs a bunch of file names then
uses portions of the file names. As with most things in
UNIX/Linux there are multiple ways of doing things, zsh is no
exception. While trying different approaches to the task I ran
into an index issue I don't understand. Using the parameter
expansion flags (SB) and (SE) to find the beginning and end
of a match I was surprised when the ending index returned the
end of the match + 1.
The man page states:
B Include the index of the beginning of the match in the result.
E Include the index of the end of the match in the result.
Logic to me would be, if the B flag returns the index of the first
character of the match, then the E flag should return the index
of the last character of the match, not +1.
Am I missing something here?
Alternately using the conditional expression
"string =~ regexp", the integer parameters MBEGIN and MEND
work as expected.
Also in researching this I found an example of using the E flag.
The example uses a variable with a string of 10 characters,
yet using the (SE) flags the match returned an index of 11.
Should a returned index be larger the the length of the variable?
Again, just trying to understand what I'm missing here.
Thanks in advance for your help.
Sincerely,
Jim
Messages sorted by:
Reverse Date,
Date,
Thread,
Author