help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: regular expression


From: Emanuel Berg
Subject: Re: regular expression
Date: Mon, 30 Jun 2014 22:52:41 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Teemu Likonen <tlikonen@iki.fi> writes:

> It's very likely that when one writes [A-Za-z] he
> actually means "match any letter". So it's often
> better to write [[:alpha:]] instead since it also
> matches other letters than A-Z. Sometimes a good
> option is \w which matches word-constituent
> characters as defined in the current syntax table.

I actually think A-Z and so on is clearer to read and
faster to write, but good point, the char classes
probably makes for more "portable" stuff because
[[:alpha:]] includes the Swedish chars ä, å, and ö as
well (and the German, Finnish, etc., I would suppose) -
I don't know if this somehow plays with your locale
(that'd be impressive) or if [[:alpha:]] is just very
generous. Like I said, A-Z is clearer! But you should
use [[:alpha:]], of course - as for this particular
question, there are also [[:upper:]], [[:lower:]],
[[:digit:]], [[:space:]]. Note the double square
brackets - otherwise [:digit:] would be :, d, i, g, i,
t - so it could look like this: [[:alpha:][:digit:]]

(replace-regexp "[[:alpha:][:digit:]]" "x")

One1 (will be xxxx)

PS. Boy, I really hope the OP did as I said and came to
gnu.emacs.help! DS.

-- 
underground experts united:
http://user.it.uu.se/~embe8573


reply via email to

[Prev in Thread] Current Thread [Next in Thread]