Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have hundreds of files to look in to check if there is not an extra line with a space which cause my PHP application to throw hundreds of Warning in the logs.

I cannot find the regex to match a space (or tab) at the end of a file.

share|improve this question
up vote 6 down vote accepted

Please note, this seems to only work in Notepad++ 6.0 (or above).
Version 6.0 included support for PCRE, which is required for this to work.

Search for \z (That's a space, followed by a backslash, followed by the letter z). That should do :)

\z marks the end of the file.

enter image description here

If you want to find any whitespace at the end of the file, use \s+\z. \s means any whitespace character:

enter image description here

share|improve this answer
I tried your solution but it doesn't work with my Notepad++ on Windows 7, have you tried it yourself ? – Gueno May 22 '12 at 16:59
@Gueno: Yes. Worked like a charm (also on Windows 7). I even tested with possible false positives. Maybe it's not actually a space. – Oliver Salzburg May 22 '12 at 17:10
I may have the wrong parameters somewhere... Regex mode or extended mode ? I do have a space when testing in a dummy file, I even tested with the letter 'k' instead of a space as last line, but k\z doesn't match it :( – Gueno May 22 '12 at 17:28
@Gueno: Maybe it's a version issue. I have Notepad++ 6.1.2 (just updated) but it also worked with 6.0 (before I updated). The mode is "Regular expression" (as in the screenshot). – Oliver Salzburg May 22 '12 at 17:37
maybe, I use 5.9.1, will try to update it and come back to give feedback – Gueno May 22 '12 at 17:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.