Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Parameter Expansion pattern compatibility


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..


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:


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,


Messages sorted by: Reverse Date, Date, Thread, Author