In Notepad++, I have many lines in the format:
abc.xyz
where "abc" might have space or - or numbers.
How do I delete lines without "."? So if a line does not have any ".", I want it removed completely, not even leave an empty line.
In Notepad++, I have many lines in the format:
abc.xyz
where "abc" might have space or - or numbers.
How do I delete lines without "."? So if a line does not have any ".", I want it removed completely, not even leave an empty line.
.?Menu "Search" > "Replace" (or Ctrl + H)
Set "Find what" to ^[^\.]*\r\n
\r\n with different EOL (End of Line) regular expressions depending on the EOLs in your file (see "I have a different EOL in my file, what can I do?" and "I don't care what EOLs my file uses, what can I do?" below).Clear "Replace with"
Enable "Regular expression"
Click "Replace All"
Notes:
The above assumes that the last line in the file has a trailing EOL.
The above also assumes you are editing a text file with Windows EOLs, \r\n.
Before:
abc.xyz
abcdef
abc 123.xyz
abc 123def
After:
abc.xyz
abc 123.xyz
The Windows EOL is \r\n.
If you are using files with a different EOL you can convert them to Windows EOLs using Menu "Edit" > "EOL Conversion".
If you aren't working with Windows EOLs, and you don't wish to convert them, use the following instead:
Use \n instead of \r\n for Unix/OS X EOLs
Use \r instead of \r\n for Mac OS (up to version 9) EOLs
You can use \R or (?:\r\n?|\n) or (?:\r?\n?) instead of \r\n. This gets around any issue with the EOLs actually used in the file.
You can also use (?:\r?\n?|$). This expression will work if there is no EOL in the last line of the file.
The accepted answer is correct, but you won't always have regex at ready. So I present a simpler solution.
.