emacs-devel
[Top][All Lists]
Advanced

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

Re: How do I get a ] into a reg exp?


From: David Kastrup
Subject: Re: How do I get a ] into a reg exp?
Date: Wed, 13 Sep 2006 22:21:17 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Lennart Borgman <address@hidden> writes:

> How do I write
>
>    (re-search-forward "[a-z\]]")
>
> I mean how do I get the ] into the characters to search for? It works
> if I remove a-z. Looks like a bug to me.

\] is the same as ] in string syntax.  Anyway:

(info "(emacs) Regexps")

     To include a `]' in a character set, you must make it the first
     character.  For example, `[]a]' matches `]' or `a'.  To include a
     `-', write `-' as the first or last character of the set, or put
     it after a range.  Thus, `[]-]' matches both `]' and `-'.

     To include `^' in a set, put it anywhere but at the beginning of
     the set.  (At the beginning, it complements the set--see below.)


-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum




reply via email to

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