Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 -?

share|improve this question

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
share|improve this answer
That was just awesome! I used (-[0-9]+) and it removed just what I wanted, thank you so very much! – user203592 Mar 2 '13 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+ *) – Radoo Mar 2 '13 at 11:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.