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

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

Re: re-search-backward does not properly report starting point or matchi


From: Barry Margolin
Subject: Re: re-search-backward does not properly report starting point or matching string
Date: Thu, 09 Oct 2003 18:49:12 GMT

In article <mailman.1430.1065723442.21628.bug-gnu-emacs@gnu.org>,
>Eval the following, trivial, test function:
>
>(defun z-test ()
>   (interactive)
>   (re-search-backward "[a-z]+")
>   (message (format "point: %d, beginning: %d, end: %d, string: %s" 
>(point) (match-beginning 0) (match-end 0) (match-string 0)))
>   )
>
>Then, place cursor at the end of the string "sdfds" and run
>z-test. A message like this will show up:
>
>point: 1446, beginning: 1446, end: 1447, string: s
>
>It reports only on the last character matched by the pattern.
>
>It seems to me that re-search-backward works conceptually differently
>from an search-backward, search-forward and re-search-forward. It does
>not "advance" (backwards) the cursor to the real beginning of the
>pattern, like the other functions, including search-backward do (see
>more on this at *1*). But, whatever justification there might be for
>that (if there is any), clearly, the "match-string" is incorrect.

A search stops as soon as it finds a string that matches the pattern.  When
starting from the end of the string "sdfds", it goes back one character and
discovers that it has a match, so it stops immediately.  The fact that it
would also have a match that ends at the same place if it kept searching
backward is irrelevant.

-- 
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.




reply via email to

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