Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: regexing to remove punctutation in telephone numbers
- X-seq: zsh-users 6860
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Eric Smith <es@xxxxxxxxxxxx>
- Subject: Re: regexing to remove punctutation in telephone numbers
- Date: Wed, 10 Dec 2003 14:44:34 +0100
- Cc: Zsh users list <zsh-users@xxxxxxxxxx>
- In-reply-to: <20031210131756.GA29126@xxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20031210124617.GA3027@xxxxxxxxxxxx> <7336.1071061393@xxxxxxx> <20031210131756.GA29126@xxxxxxxxxxxx>
Eric Smith wrote:
>
> >
> > myfax () {
> > command myfax "${1//[-()]}${2//[-()]}" ${argv[3,-1]}
> > }
>
> There can be n number of args with the offending punctutation characters.
> And n should be determined from the first arg that commences in a non
> [-()0-9] character.
myfax() {
local last=${argv[(i)[^-()0-9]*]}
command myfax "${(j..)argv[1,last-1]//[-()]}" "$argv[last,-1]"
}
That uses the (i) subscript flag to find the first arg commencing with
a different character. I'd be inclined to check all characters:
(^[-()0-9]#)
You could use a loop to do the same.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author