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

前端 未结 3 1152
清酒与你
清酒与你 2020-12-31 15:31

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

相关标签:
3条回答
  • 2020-12-31 15:59

    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.

    0 讨论(0)
  • 2020-12-31 16:01

    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.

    0 讨论(0)
  • 2020-12-31 16:13

    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.

    0 讨论(0)
提交回复
热议问题