[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trouble in understanding the behavior of search-backward-regexp
From: |
Alain Cochard |
Subject: |
Re: Trouble in understanding the behavior of search-backward-regexp |
Date: |
Mon, 07 Sep 2009 18:52:17 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
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