[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Strange behavior in search-forward-regexp?
From: |
Mathias Dahl |
Subject: |
Strange behavior in search-forward-regexp? |
Date: |
Sat, 11 Feb 2006 02:43:26 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Take these "buffers":
Buffer 0:
---------- this line is not part of the buffer ----------
row0;test0
row1;test1
row2;test2
---------------------------------------------------------
Buffer 1:
---------- this line is not part of the buffer ----------
row0;test0
row1;test1
row2;test2
---------------------------------------------------------
Evaluate these functions:
(defun test1 ()
(interactive)
(save-excursion
(goto-char (point-min))
(if (search-forward-regexp "^[^;]+;.*test1" nil t)
(message (match-string-no-properties 0)))))
(defun test2 ()
(interactive)
(save-excursion
(goto-char (point-min))
(if (search-forward-regexp "^.*test1" nil t)
(message (match-string-no-properties 0)))))
In buffer 0, test1 and test2 willreturn the same result, "row1;test1",
but in buffer 1, test1 will return "\nrow1;test1" (\n is a newline)
and test2 "row1;test1".
Can someone explain this to me? Why would, in the case of test1, the
newline be included just because the line before is empty?
- Strange behavior in search-forward-regexp?,
Mathias Dahl <=
Re: Strange behavior in search-forward-regexp?, Peter Dyballa, 2006/02/11