0

So I exported a mySQL database, so far everything has been easy to edit in Notepad++. However, every new line starts with a -123456 random number string.

Is there a way to remove all string that start with -?

1 Answer 1

1

Yes. There is. It's finding and replacing a line through regular expressions:

-[0-9]+ *(.*)

Edit: shorter form: -\d+ *(.*)

Then all you have to do is replace the whole line with the first group, which is .*. This will remove the number there.

enter image description here

If you want to delete the whole line, then you don't need groups. But you need the end of line character to be removed. So:

  1. Remove the matched regexp line string. If you don't want to delete empty lines you already have than I suggest replacing your string with something unique like RRRRRRRRRRR. enter image description here
  2. Then, you need to use extended mode, not regular expressions, to remove RRRRRRRRRRR plus the new line character (depending on the file format, the new line might represent two bytes or one byte, but on Windows files is CR+LF which in Notepad++ represents \r\n), by replacing them with nothing. enter image description here
2
  • That was just awesome! I used (-[0-9]+) and it removed just what I wanted, thank you so very much!
    – user203592
    Mar 2, 2013 at 11:49
  • I think you want to remove white spaces as well, that's the " *". I guess I complicated things a bit. I guess (-[0-9]+ *) works just fine for you. There's actually a shorter form... (-\d+ *)
    – user127350
    Mar 2, 2013 at 11:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .