Menu

Need help with removing to end of line

2008-01-17
2012-11-13
  • Nobody/Anonymous

    Below is a sample.....
    Can anyone tell me how to use search and replace to remove everything after the .zip. I don't want the info or size there

    Good Night!.zip  ::INFO:: 33Kb
    Soggy Bottom Boys, The - I Am A Man Of Constant Sorrow.zip  ::INFO:: 4.02Mb
    Keith, Toby - I Wanna Talk About Me.zip  ::INFO:: 2.97Mb
    Turner, Josh - Long Black Train.zip  ::INFO:: 3.86Mb
    Wills, Mark - 19 Somethin'.zip  ::INFO:: 3.21Mb
    McGraw, Tim - Real Good Man.zip  ::INFO:: 4.06Mb
    Chesney, Kenny - There Goes My Life.zip  ::INFO:: 4.19Mb
    McGraw, Tim - She's My Kind Of Rain.zip  ::INFO:: 4.38Mb

     
    • Nobody/Anonymous

      Yes, correct, however, there is nothing to delete if you do not select the text.:)

       
      • Nobody/Anonymous

        Yes, correct, when it's raining, it isn't dry, but what's that got to do with it?

         
    • fidvo

      fidvo - 2008-01-17

      You can do it in the Simple Script plugin with a one-line tag:

      deletefromtag("zip",3)

      The 3 is an offset, which tells it not to delete the next 3 characters starting at the "z" in "zip".  (If the offset were 0, the "zip" would be removed as well)

      If you don't have the Simple Script plugin, you'll need to download it from the downloads page.

      I'm sure you can do it in a regular expression as well, but I'm not familar enough with regex to be able to help you there.

       
      • Nobody/Anonymous

        here's yet one other way to do it (hyoowtdi):

        in Find and Replace:

        check Regular Expression box, then

        find: (\.zip).*

        replace with: \1

         
    • Nobody/Anonymous

      Using regular expressions in either the CTRL+F/H or CTRL+R Replace dialog:
      Find Field:
      \.zip_::INFO::_.+$ (_ represents a space)
      Replace Field:
      .zip

      I included the .zip extension to get a more correct match, although it is not likely that ::INFO:: will occur in the names. The \ is used to indicate that the character . has to be matched. The . itself has a special meaning, see next line.
      This regex searches for the ::INFO:: identifier and "anything behind it" (. = any character, + = one or more) "until the end of the line" ($)

      The found string will be replaced by .zip, so it leaves anything you want.

       
    • Greg Bullock

      Greg Bullock - 2008-01-18

      And here's yet another way.

      Press Ctrl-F and set the "Find what" box to ".zip".  Click the Close button.

      Record the macro:
      <Home> <F3> <Right> <Shift-End> <Delete> <Down>

      Replay the macro until the end of the file or as many times as required.

      Regards.
      Greg

       
      • Nobody/Anonymous

        > <Home> <F3> <Right> <Shift-End> <Delete> <Down>

        Even worse... I guess the last key should be a <CursorRight> instead of a <Down> because this may skip a .zip occurring before the current cursor position.

         
        • Greg Bullock

          Greg Bullock - 2008-01-18

          > Even worse... I guess the last key should be a <CursorRight> instead of a <Down> because this may skip a .zip occurring before the current cursor position.

          The <Home> key at the beginning of the macro already accounts for that eventuality.

          Regards.
          Greg

           
          • Nobody/Anonymous

            I can't argue that <Alt+Home> would be better, because normally there won't be any text before the <Home> position. But then again, looking at the user's request... Why record a macro for something that can be done right-away?

             
      • Nobody/Anonymous

        ... and possibly there are lots of other and more elaborate ways to possibly get the same result.

        This macro will only work as long as the Find field isn't changed, which probably won't be a problem if you execute it for all occurrences at once.
        However, it only searches for ".zip", so if there is a humorous artist called "T.zipper", he will be cut into half.

        The same goes for the short regex (\.zip).*. This will also cut "T.zipper" into one half-piece, because it will take anything behind the first match in a line.

        Be aware of this, when you want to specifically delete parts of lines that are identified by some (other) text.

        Can anyone tell me why ".*" won't match empty lines? By itself it is a "valid" expression which should also match no-character-at-all. Since this kind of regex works on a per-line basis, I think also the "empty part" before the CR/LF should be matched.

         
        • Greg Bullock

          Greg Bullock - 2008-01-18

          >This macro will only work as long as the Find field isn't changed, which probably won't be a problem if you execute it for all occurrences at once.

          The macro works even after the Find field is changed.  Before running the macro, the user must ensure that the Find field is prepopulated appropriately, with either the same ".zip" string or some other key string the user prefers to use.

          Regards.
          Greg

           
    • Nobody/Anonymous

      To delete to the end of line:

      Position cursor somewhere in the middle of a line.
      Macro -> Start Recording.
      SHIFT-END
      SHIFT-END
      DELETE
      Macro -> Stop Recording.

       
      • Nobody/Anonymous

        Wow, what does this _actually_ do? It deletes to the end of the line and records this action as a macro. Great! Can I then use this macro?

         
    • Nobody/Anonymous

      Yes, give the macro a shortcut or use it from the Menu:
      Macro --> macro selection

      The macro selects the text from the cursor to the end of line (even when line wrapping is active (that's why 2x SHIFT-END command)).

      Then it deletes the selected text.

      The only disadvantage is that the text is placed on the clipboard, but it's not a problem for me.

       
      • Nobody/Anonymous

        If you press SHIFT+DELETE the text will be copied (cut) to the clipboard. Pressing DELETE only results in the text only being deleted, without any clipboard copy.