Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Substitution question
- X-seq: zsh-users 7715
- From: DervishD <raul@xxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Substitution question
- Date: Tue, 20 Jul 2004 09:15:55 +0200
- In-reply-to: <s38pt6r4gz1.fsf@xxxxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: Pleyades
- References: <s38pt6r4gz1.fsf@xxxxxxxxxxxxxxxxxx>
Hi Björn :)
* Björn Lindström <bkhl@xxxxxxxxxxxxxxx> dixit:
> Can somebody tell me what type of patterns are supported in l, in the
> $x:s/l/r syntax?
Read the info manual, section 'History Expansion', node
'Modifiers'. Scroll down a bit and you'll find the answer. The 'l'
part is not a regex :(
> I'd like to do something like:
>
> $x:gs/[^A-Za-z0-9]/_
>
> to replace all characters except for the ones listed with underscore.
¿How about using ${x//PATTERN/REPLACEMENT}? Then you can use the
patterns valid for filename generation (sort of a regex, more or less
powerful depending on the option 'EXTENDED_GLOB'. For your example, I
would do:
print ${x//[^[:alnum:]]/_}
Whether to use 'print' or not is up to your particular use. The
double '//' is to say 'make substitutions global, not only the
first', and the 'regex' is to say 'al non alphanumeric characters'.
Hope this helps.
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author