help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Trouble in understanding the behavior of search-backward-regexp


From: Joost Kremers
Subject: Re: Trouble in understanding the behavior of search-backward-regexp
Date: 7 Sep 2009 16:17:10 GMT
User-agent: slrn/0.9.9 (Linux)

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.


-- 
Joost Kremers                                      joostkremers@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


reply via email to

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