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

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

Re: re-search-backward bug


From: Andreas Schwab
Subject: Re: re-search-backward bug
Date: Tue, 08 Oct 2002 18:05:13 +0200
User-agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.3.50 (ia64-suse-linux)

Tom Wurgler <address@hidden> writes:

|> 1) Have a decimal number in a buffer, for example:
|> 
|> 1234.456
|> 
|> 2) Have your cursor BEFORE the number
|> 3) Do esc-x re-search-forward "[0-9]*\.[0-9]*"
|>    The complete number "1234.456" is found.
|> 4) Now have the cursor start AFTER the number
|> 5) Do esc-x re-search-backward "[0-9]*\.[0-9]*"
|>    It only matches back to the ".", specifically ".456"  
|> 
|> Why is going backward different than going forward?

Because matching by regexp is an inherently forward going operation.  It
is (conceptionally) implemented by going character by character until the
regexp matches.  That means that when going backwards the first match is
actually the _last_ match when viewed in the forward direction.

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 N├╝rnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

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