Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Parameter Expansion pattern compatibility
- X-seq: zsh-users 13573
- From: "Jerry Rocteur" <macosx@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Parameter Expansion pattern compatibility
- Date: Wed, 10 Dec 2008 15:44:11 +0100 (CET)
- Importance: Normal
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
Hi,
I have one that I can sovle by using perl inside my zsh script but if anyone has time, I'm curious as to why it fails
on zsh..
echo $ZSH_VERSION
4.2.6
Given a list of strings like this
set -A userId p0btu pabtu p11btu p11eb41 rs0bt2 jro dri
I would like to see btu btu btu eb41 bt2 jro dri
if string begins with any case prt and is followed by one and one only [0-9] or [a-z] folowed by any mumber of digits.
Remove everything up to the last digit.
In ksh we did it like this ${userId[$i]##([pPRrTt]@([0-9]|[a-z])*([0-9]))}
In zsh it does not remove anything.
I repaced it with this:
echo ${userId[$i]}|perl -pe 's/^[pPrRtT]([0-9]|[a-z]){1}[0-9]*//'
I thought I had foudn the answer on this page:
http://zsh.dotsrc.org/FAQ/zshfaq02.html
So I tried several variations of this: ${userId[$i]##([pPRrTt]([0-9]|[a-z])[0-9]#)} But I couldn't get it to do it
like I needed it.
Of course, there may be a sexier zsh way to do it, I'm also very interested in that.
Thanks in advance,
Jerry
Messages sorted by:
Reverse Date,
Date,
Thread,
Author