Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Match length and multibyte characters
- X-seq: zsh-users 20537
- From: Erik Bernstein <erik@xxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Match length and multibyte characters
- Date: Thu, 10 Sep 2015 13:35:51 +0200
- 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
Hello everybody,
while playing around with zsh expansions, I've stumbled across this
small annoyance that I think might be worth to ask the list about.
Let's suppose I have an array and I want to know the length of the
longest string contained. After going through zshexpn(1), the first
thing I came up with was:
% array=(a bbb cc)
% print ${${(O)array//(#m)*/${#MATCH}}[1]}
3
which is perfectly fine and seems to do the job. Later I found that
the same thing can be accomplished by this.
% print ${${(ON)array%%*}[1]}
3
However, the second version seems to break on multibyte characters
while the first one works just fine:
% array=(a ä a)
% print ${${(O)array//(#m)*/${#MATCH}}[1]} ${${(ON)array%%*}[1]}
1 2
Can maybe someone shed some light on whether the second version is
supposed to work with multibyte characters and, if, what has to be
done to make it count multibyte chars only once just like the first
version does?
regards
erik
Messages sorted by:
Reverse Date,
Date,
Thread,
Author