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

情到浓时终转凉″ 提交于 2019-12-18 13:16:55

问题


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

Each line is a different length and has different characters so cant use anything as delimiters.


回答1:


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

.{13}$

Then replace it with nothing. And of course you could use a more expressive regex to match only dates in your particular format and nothing else.




回答2:


As others already said, use a regex search in the search and replace dialogue (ctrl + h) with the pattern the dates follow. Given your example this should do:

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

Replace with empty string.




回答3:


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

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

EDIT. On second look I see that you mentioned the lines are of different length. So this might not work in your case. Anyways I will leave it as it is. Who knows it might come in handy later, or maybe for someone else.



来源:https://stackoverflow.com/questions/15454869/how-to-remove-the-last-13-or-n-characters-of-every-line-using-notepad

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!