Menu

Some more "advanced" mass replacement/delete?

2007-09-13
2012-11-13
  • Nobody/Anonymous

    Ok, I've looked around and haven't been able to find features of this wonderful program that will do my bidding. And before I start, I don't know how to program.

    I'm looking for a way to do the following:

    1. Completely delete a line where a specific character or word comes up (for instance, "/")

    2. Delete all lines that don't meet a specific minimum and maximum length (for example, every line that isn't between 6-10 characters).

    3. It seems like I'm overlooking this one, but is it possible to delete all marked lines? It would make #1 a lot easier if I just mass-marked every line with a "/" in it via Find and just deleted them all. Or maybe even marking lines that are between 6-10 characters long and deleting everything that ISN'T marked, although neither of that seems to be possible.

    I'd greatly appreciate any help, though. I'm dealing with some pretty big files that I need to consolidate and touch up a little.

     
    • Chris Severance

      Chris Severance - 2007-10-01

      Minor correction:

      It's not actually a column selection. It's a standard selection that begins at the column you want sorted. The sort tool will sort the entire first line even though you haven't selected all of it.

       
    • Nobody/Anonymous

      open replace dialog, check "Regular expression"

      1.
      in find editbox type .*/.*
      replace edit-box leave blank
      press replace all

      2.
      same as previews, but first type ^.$
      replace all
      then type ^..$
      replace all
      and so on up to 5 dotes - this will delete lines with letters < 6
      and then once type ^...........*$
      and replace - this will delete lines with letters > 10

      Regexes in notepad++ are very poor... With better regex engine this all could be done with 1 line :)

       
      • Nobody/Anonymous

        Thanks. I'm wondering, is there also a way to delete duplicate lines without having to be specific about which text should be searched for duplicates of?

        I want to keep the first line of anything with duplicates, then delete all the duplicate lines without specifying any specific text to search for. Hard, maybe...

         
        • pshute

          pshute - 2007-09-18

          To delete duplicate lines you could use TextFX Tools to sort the file with the "sort outputs only unique lines" option turned on.  Sorting will mess up the order of your file, so you should use TextFX Tools to insert line numbers first.  Then do a column selection so that the sorting doesn't look at the line numbers.

          After sorting, sort all the lines again after selecting the whole file, so that the lines get sorted back into their original order using the line numbers.  Then use TextFX Tools to delete the line numbers.

          You'd think there could be an easier way.

           
MongoDB Logo MongoDB