0

I have multiple files with text like ...

<studio>Morabito Picture Company</studio>
<trailer>plugin://plugin.video.youtube/?action=play_video&amp;videoid=QFbC5XGMOvI</trailer>
<dateadded>2016-10-16 22:25:51</dateadded>

I would like to remove anything except the URL between <trailer> and </trailer>.

How is this possible in Notepad++ ?

2 Answers2

0

You could use the replace function (CTRL+H) in Notepad++ and a regular expression like this:

.*<trailer>(.+)</trailer>.*

The parentheses catch whatever is stored in between them in variable \1. Just type \1 in the "replace with:" field and make sure that you have selected the ". matches newlines" alternative.

It is also possible to apply this to all files in a directory by using the Find in Files function (CTRL+SHIFT+F) clicking the button "Replace in Files". Be cautious though as to not change any data unintentionally.

Keshan Nageswaran
  • 8,060
  • 3
  • 28
  • 45
internetional
  • 312
  • 2
  • 8
0

Using Replace in Notepad++ with Ctr+H or Menu->Search->Replace, where you tick Regular expression.

  1. Remove all other tags with content between opening and closing tag, with the following line:

    <(?!trailer).>.?</(?!trailer).*> in Find what and nothing in Replace With field and click Replace All.

  2. Replace<trailer>url</trailer> with url. Write:

    <trailer>(.*?)</trailer>

in Find what field and

$1 

in Replace With field. Click Replace All.

Edit: To get rid of the redundant empty lines use:

[\n\r]+$

in Find what and nothing in Replace With and click Replace All. This is from: https://stackoverflow.com/questions/3866034/removing-empty-lines-in-notepad

Community
  • 1
  • 1
αNerd
  • 528
  • 1
  • 6
  • 11