-2

This is only one line, I have thousand in a file http://img6a.flixcart.com//image/mobile/z/r/j/micromax-bling-q55-bling-limited-iifa-edition-400x400-imadfebcbg7yzrmh.jpeg,http://img5a.flixcart.com//image/mobile/z/r/j/micromax-bling-q55-bling-limited-iifa-edition-75x75-imadfebcbg7yzrmh.jpeg

MShadN N
  • 5
  • 1

2 Answers2

3

Input:

http://img6a.flixcart.com//image/mobile/z/r/j/micromax-bling-q55-bling-limited-iifa-edition-400x400-imadfebcbg7yzrmh.jpeg,http://img5a.flixcart.com//image/mobile/z/r/j/micromax-bling-q55-bling-limited-iifa-edition-75x75-imadfebcbg7yzrmh.jpeg

Find and replace in regex mode:
Find what: ^(.*?jpeg).*$
Replace with: \1

enter image description here

Result:

http://img6a.flixcart.com//image/mobile/z/r/j/micromax-bling-q55-bling-limited-iifa-edition-400x400-imadfebcbg7yzrmh.jpeg

Explanation:

^            Start of string
(.*?jpeg)    Everything until first jpeg, stored in group \1
.*           followed by any number of characters
$            end of line
RaGe
  • 22,696
  • 11
  • 72
  • 104
2

Here is what I would do, using a macro:

You have a thousand lines of the form

http://www.alice.com/bob.jpeg;http://www.wolf.com/rabbit.jpeg

which you would like to turn into

http://www.alice.com/bob.jpeg

by deleting everything after the first instance of ".jpeg".

  • Back the file up.
  • Open the file in Notepad++ (obviously).
  • Go to the Macro -> Start recording menu item.
  • Go to the Find dialog by pressing Ctrl+f.
  • Make sure that the settings are:
    • Match whole word only: unchecked;
    • Match Case: unchecked;
    • Wrap Around: unchecked;
    • Search Mode: 'Normal';
    • Direction: Down.
  • Enter ".jpeg" and press Enter. This will select the next instance of .jpeg after the cursor.
  • Press Escape. This will dismiss the "Find" window.
  • Press Right. This will clear the selection and move the cursor to after the .jpeg.
  • Press Shift+End. This will select the rest of the line after the .jpeg.
  • Press Delete to delete the selection.
  • Press Right to move the cursor to the start of the next line.
  • Go to the Macro -> Stop recording menu item.

At this point, the macro is set up and should will be ready to use.

Go to the Macro -> Playback menu item to test it on the next line.

If that works as you expect, try the Macro -> Run a macro multiple times menu item and try to run it a few times (be cautious to start with, say, five times).

If, at this point, the result is as you expect, you're good to go! Enter a larger number in the Run a macro multiple times menu item to get close to the end of the file, then use the Playback item (or press Ctrl+Shift+P) to do the last few ones.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92