From: David Kastrup <dak@gnu.org>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: How do I get a ] into a reg exp?
Date: Thu, 14 Sep 2006 00:07:22 +0200 [thread overview]
Message-ID: <85bqpjfmjp.fsf@lola.goethe.zz> (raw)
In-Reply-To: <45087C92.30407@student.lu.se> (Lennart Borgman's message of "Wed\, 13 Sep 2006 23\:48\:02 +0200")
Lennart Borgman <lennart.borgman.073@student.lu.se> 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
next prev parent reply other threads:[~2006-09-13 22:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-13 19:45 How do I get a ] into a reg exp? Lennart Borgman
2006-09-13 20:16 ` David Hansen
2006-09-13 20:26 ` David Kastrup
2006-09-13 20:21 ` David Kastrup
2006-09-13 21:31 ` Lennart Borgman
2006-09-13 21:35 ` Drew Adams
2006-09-13 21:42 ` Lennart Borgman
2006-09-13 21:48 ` Lennart Borgman
2006-09-13 22:07 ` David Kastrup [this message]
2006-09-13 22:10 ` Drew Adams
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=85bqpjfmjp.fsf@lola.goethe.zz \
--to=dak@gnu.org \
--cc=emacs-devel@gnu.org \
/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.savannah.gnu.org/cgit/emacs.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).