Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Getting a particular char
- X-seq: zsh-users 7816
- From: DervishD <raul@xxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: Re: Getting a particular char
- Date: Tue, 10 Aug 2004 13:51:30 +0200
- In-reply-to: <20040806105541.GE24158@DervishD>
- Mail-followup-to: Zsh Users <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: Pleyades
- References: <20040806105541.GE24158@DervishD>
Hi all :)
* DervishD <raul@xxxxxxxxxxxx> dixit:
> If I want to get the character number 'n' from a parameter
[...]
> So I change it to something like 'expr substr $parameter n 1'.
> This has some problems, like '$parameter' needing some tweaking so
> 'expr' doesn't whine because it starts with '(', '+', etc. or it is
> something like the word 'match'. But all that is not important,
> because the 'substr' expression is not SUSv3 compliant, so I cannot
> do that neither.
Finally I did this way (thanks to Paul Eggert, coauthor of GNU
coreutils, for the help):
expr "x$parameter" : ".\{n\}\(.\)"
Where 'n' is the index of the character we want. Easy and fully
SUSv3 compliant, where {N} is a valid BRE for repetition.
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author