From: DervishD <raul@pleyades.net>
To: zsh-users@sunsite.dk
Subject: Re: Substitution question
Date: Tue, 20 Jul 2004 09:15:55 +0200 [thread overview]
Message-ID: <20040720071555.GB8475@DervishD> (raw)
In-Reply-To: <s38pt6r4gz1.fsf@numerus.ling.uu.se>
Hi Björn :)
* Björn Lindström <bkhl@elektrubadur.se> 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/
prev parent reply other threads:[~2004-07-20 7:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-20 1:14 Björn Lindström
2004-07-20 7:15 ` DervishD [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040720071555.GB8475@DervishD \
--to=raul@pleyades.net \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).