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

Re: regexing to remove punctutation in telephone numbers



Peter Stephenson said:
> Eric Smith wrote:
> > Could someone suggest a neat zsh way to convert
> > 
> > $ myfax 00-(123) 4567-890 _some_file_name_ AnotherFileName.ps whatever
> > 
> > to
> > 
> > 001234567890 _some_file_name_ AnotherFileName.ps whatever
> 
> I don't know how flexible you want to be, but:

Thanks Peter,

Thats exactly the point ...

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

-- 
Eric Smith



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