0

I have a text file with diferent lines.

A few of the lines terminate in values such as 000, 001, 002, other have different terminations, aaa, bbb etc..

The problem is, I have nearly 100 different ending values, in a thousand of lines text.

So I'm looking for a way to make this easier, as an example.

aldskjflaskdjh-000
alskdjfhlakjsd-001
alskdjfhlakjsd-002
alskdjfhlakjsd-003
alskdjfhlakjsd-aaa
alskdjfhlakjsd-bbb
alskdjfhlakjsd-ccc

I want it to delete all the files that end in a group of 3 numbers, so I'd only be left with

alskdjfhlakjsd-aaa
alskdjfhlakjsd-bbb
alskdjfhlakjsd-ccc

I've tried sublime 2, searching for -000, choose all, select the lines and press "del". But having nearly -100 in some cases turns out very hard to clean it up.

Does anyone knows a easier solution for this?

Thanks in advance

  • Have a [look at this](https://stackoverflow.com/questions/918158/how-to-delete-specific-lines-on-notepad?rq=1) – boop_the_snoot Sep 17 '17 at 17:24
  • You could click alt + mark all the lines with you mouse. Then you can delete / change the entries. This will only work if the length of all the rows are the same. – Matthias Gwiozda Sep 17 '17 at 17:26

1 Answers1

2
  • Ctrl+H
  • Find what: ^.+?-\d{3}(?:\R|$)
  • Replace with: LEAVE EMPTY
  • Replace all

Explanation:

^               : begining of line
  .+?       : 1 or more any character, not greedy
  -         : a dash
  \d{3}     : 3 digits
  (?:       : start non capture group
    \R      : any kind of linebreak
   |        : OR
    $       : end of line
  )         : end group
  • check Wrap around
  • check Regular expression
  • DO NOT CHECK . matches newline

Result for given example:

alskdjfhlakjsd-aaa
alskdjfhlakjsd-bbb
alskdjfhlakjsd-ccc
Toto
  • 89,455
  • 62
  • 89
  • 125