zsh-users
 help / color / mirror / code / Atom feed
From: DervishD <raul@pleyades.net>
To: Zsh Users <zsh-users@sunsite.dk>
Subject: Re: Getting a particular char
Date: Tue, 10 Aug 2004 13:51:30 +0200	[thread overview]
Message-ID: <20040810115130.GD1825@DervishD> (raw)
In-Reply-To: <20040806105541.GE24158@DervishD>

    Hi all :)

 * DervishD <raul@pleyades.net> 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/


  reply	other threads:[~2004-08-10 11:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-06 10:55 DervishD
2004-08-10 11:51 ` DervishD [this message]
2004-08-06 11:24 Sean Johnston

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040810115130.GD1825@DervishD \
    --to=raul@pleyades.net \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).