How to remove the last 13 (or n) characters of each line using Notepad ++

I have a file in which each line ends on Mar 15, 2013 and other dates, so I need to delete the end of each line, say, the last 13 characters

Each line has a different length and has different characters, so it cannot use anything as delimiters.

+6
source share
3 answers

You can use the regular expression in search and replace -dialog ( Ctrl + H ), which is anchored to the end of the line:

 .{13}$ 

Then replace it with nothing. And, of course, you can use a more expressive regular expression to match only dates in your specific format and nothing more.

+20
source

As others have said, use the regular expression search in the search and replace dialog box (ctrl + h) with the pattern below. Given your example, this should do:

 [A-Za-z]{3}\s(\d){1,2},\s?\d{4}$ 

Replace the empty string.

0
source

Just to give you an alternative. You can also use the column editing mode.

Press Alt and Left click your mouse and move the mouse vertically along all the lines you want to edit. Then you can simply delete everything starting from this column.

EDIT. In the second glance, I see that you mentioned that the lines have different lengths. So this may not work in your case. In any case, I will leave it as it is. Who knows that this may come in handy later, or maybe for someone else.

0
source

All Articles