Salexes
Salexes

Reputation: 187

Remove/strip specific Html tags using NotePad++

Here is my text:

<a class="attachment-link" href="http://www.example.com/example-example/?example_id=example-example.jpg">

and I want to completly remove all of it.

There are several hundrets of those entries, I want to remove all entrys

so I tried to use this regex in Notepad++ to replace with nothing:

<a .*class="attachment-link" href="#">(.*?)</a>

but it doesn't work.

I am new to using regex, I would appreaciate any help

Upvotes: 0

Views: 845

Answers (1)

Washington Guedes
Washington Guedes

Reputation: 4365

I created one test.html file:

<a class="attachment-link" href="http://www.x.com/x-x/?x_id=x-x.jpg"> Some Text </a>
<a href="#"> Some Text </a>
<article>
    <a class="attachment-link" href="http://www.x.com/x-x/?x_id=x-x.jpg"> Some Text </a>
</article>

I used the "Replace All" action of Notepad++:

enter image description here

Pattern: "<a\s+class="attachment-link"(?:"[^"]*"|[^>])*>[\s\S]*?<\/a>"

And the result was:

<a href="#"> Some Text </a>
<article>

</article>

Upvotes: 1

Related Questions