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: Thu, 14 Sep 2006 00:07:22 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Lennart Borgman <address@hidden> writes:

> Lennart Borgman wrote:
>>>>
>>>> (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.)
>>>>
>>>>   
>>> Thanks. That was a surprise.
>>
>> New surprise. I still can not get it to work. This is my actual search:
>>
>>   (re-search-forward "'\\([][-+a-zA-Z~<>!;,:.'\"%/?(){}$^0|]\\)'" nil t)
>>
>>
>> The above version does not match [  -- in the parenthesis.
> But this one works:
>
>     (re-search-forward "'\\([][+a-zA-Z~<>!;,:.'\"%/?(){}$^0|-]\\)'" nil t)
>
> The - must be last. Thanks again.

Yes, [-+ is an empty range, since the first character is larger than
the last.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum




reply via email to

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