From: Alain Cochard <alain@geophysik.uni-muenchen.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Trouble in understanding the behavior of search-backward-regexp
Date: Mon, 07 Sep 2009 18:52:17 +0200 [thread overview]
Message-ID: <m3ab16elz2.fsf@frac.u-strasbg.fr> (raw)
In-Reply-To: slrnhaace7.76c.joostkremers@j.kremers4.news.arnhem.chello.nl
Joost Kremers <joostkremers@yahoo.com> writes:
> Alain Cochard wrote:
>> Hello. The trouble concerns the regular expression
>>
>> [[:blank:]]+
>>
>> for which I read that it matches any sequence of spaces and tabs.
>>
>> Let me start with search-forward-regexp, with which I have no problem.
>> Let us say I have the following sentence:
>>
>> foo bar
>>
>> with spaces and tabs between the two words
>>
>> If I put the cursor at the beginning and I use 'search-forward-regexp'
>> with this [[:blank:]]+, I end up with the cursor right on the 'b',
>> which is what I expect.
>>
>> Now, if I put the cursor at the end of that sentence and use
>> search-backward-regexp, again with [[:blank:]]+, I would expect to
>> end up on the second 'o' of 'foo'. Instead, I end up somewhere
>> between the two words, which is very mysterious to me (I have tried
>> with several combinations of emacs-version/distributions/hardware).
> it does so because a single space/tab also matches
> "[[:blank:]]+". and while emacs searches backwards, it looks forward
> for a matching string. so the first matching string it finds is the
> single space/tab directly before "bar". the cursor is then put at
> the beginning of this string.
Thanks much for the fast reply. There is this paragraph in the elisp
manual about search-forward-regexp and search-backward-regexp not
being simple mirror images, which I could not understand. I guess
this is related and I think I understand it better with your
explanation.
Thanks again,
Alain
prev parent reply other threads:[~2009-09-07 16:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-07 16:03 Trouble in understanding the behavior of search-backward-regexp Alain Cochard
2009-09-07 16:17 ` Joost Kremers
2009-09-07 16:52 ` Alain Cochard [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
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=m3ab16elz2.fsf@frac.u-strasbg.fr \
--to=alain@geophysik.uni-muenchen.de \
--cc=help-gnu-emacs@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.
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).