Search code examples
regexnotepad++

Notepad++ advanced replace function


I have this line of code inside an HTML file, and I need to remove some lines from it.

<div class="viewpoint">
<h2>View (2)</h2><a href="./Viewpoints — 100 MOUNT ST160506.nwd_files/vp0002.jpg" title="View (2)"><img src="./Viewpoints — 100 MOUNT ST160506.nwd_files/vp0002.jpg"></a><span class="namevaluepair"><span class="name">Camera Position</span><span class="value">112.933ft,&nbsp;
     93.975ft,&nbsp;
     145.095ft</span></span><div class="comments">
<div class="spacer"></div>
<div class="comment">
<h4>Comment 2</h4><span class="namevaluepair"><span class="name">Status</span><span class="value">New</span></span><span class="namevaluepair"><span class="name">User</span><span class="value">User1</span></span><span class="namevaluepair"><span class="name">Text</span><span class="value">Grid G4 - Level B5</span></span>2016/5/9&nbsp;
  0:45:10</div>
<div class="spacer"></div>
</div>ARC and STR to coordinate slab edge and raft profile<div class="spacer"></div>
</div>

Anything after

</a>

should be removed up to word "Grid...."

I tried different methods with no avail.

Enter image description here

Also, the above code repeats itself many times for each image (i.e vp0001.jpg, vp0002.jpg, etc.)


Solution

  • Try this:

    Find what: </a>.+?Grid
    Replace with: </a> Grid

    Search Mode: Regular expression, . matches newline

    enter image description here

    This gave the output of

    <div class="viewpoint">
    <h2>View (2)</h2><a href="./Viewpoints — 100 MOUNT ST160506.nwd_files/vp0002.jpg" title="View (2)"><img src="./Viewpoints — 100 MOUNT ST160506.nwd_files/vp0002.jpg"></a> Grid G4 - Level B5</span></span>2016/5/9&nbsp;
      0:45:10</div>
    <div class="spacer"></div>
    </div>ARC and STR to coordinate slab edge and raft profile<div class="spacer"></div>
    </div>