Search code examples
regexnotepad++

Single line regex search in Notepad++


When I use "Find Next" to find the next match for a regex in Notepad++ (v. 7.8.6), the match can span several lines. Is there a way to limit the matches to a single line, i.e. to search each line separately?


Solution

  • There is no option in Notepad++ to disable matching across multiple lines.

    The match texts in the Find results window are truncated, that does not mean that Notepad++ can be "set" to search within single lines.

    The ". matches newline" option only affects the . behavior: if the option is OFF, . does not match line break chars by default.

    However, \s (any whitespace chars), \W (any non-word chars), [^57] (any char but 5 and 7) patterns still may "overflow" from line to line because line break chars are among those characters those patterns match.