2

Hi can find a line that ended with LF (line feed) in notepad++ ? I only want to find a line that ended with LF without CR. Example on below, the search should only return the line 15xxxxxKL office staff.

Sample

user1902849
  • 991
  • 6
  • 22
  • 31

2 Answers2

3

You can search this with a regex like ^[^\r\n]*\n.

However, according to this answer, the ability to use \n in regular expression mode was introduced in Notepad++ 6.0. Before this version, you'd have to use the extended search mode (where you can not use a regex).

Community
  • 1
  • 1
M A
  • 65,721
  • 13
  • 123
  • 159
  • if use .*\n it will returned all line that ended in LF. In my case I only want to returned those lines that have LF without CR – user1902849 Sep 27 '15 at 16:01
  • I don't think the dot covers the carriage return character. You can also try `[^\r]*\n`. – M A Sep 27 '15 at 16:28
  • The dot matches the CR except with notepad++ (strange behavior). `[^\r]*\n` will not work because `[^\r]` contains the LF. You need to exclude it from the class too, otherwise `[^\r]*` may match several lines: `[^\r\n]*\n` – Casimir et Hippolyte Sep 27 '15 at 17:10
  • @CasimiretHippolyte Also in Java, unless you set the `UNIX_LINES` flag, the dot does not match the CR. – M A Sep 27 '15 at 17:29
0

I'd use this regex:

^.+?(?!\r)\n

Explanation:

^       : begining of line
.+?     : one or more any character (not greedy)
(?!\r)  : negative look-ahead to make sure there is not a carriage return
\n      : line feed
Toto
  • 83,193
  • 59
  • 77
  • 109