i have found many similar posts, but non of them answers my question.
I would like to replace/remove/change open and close tag with a specific key word. in this case i am trying to remove all tags whit href="#" in it….
<a href="#">leave this text</a>
<a class="" id="" href="#">leave this text too</a>
<a href="http://......">Dont remove this tag!</a>
I have this code, but i cant figure out how to leave the text…
find: <a[^h]*href="#"[^>]*> (skip content) </a>
replace: (same content)
or
replace: <a href="somthing"> (same content) </a>
Best Answer
I am trying to remove all tags containing
href="#"
Menu "Search" > "Replace" (or Ctrl + H)
Set "Find what" to
<a .*?href="#">(.*?)</a>
Set "Replace with" to
\1
Enable "Regular expression"
Click "Replace All"
Before:
After:
As pointed out by AFH in a comment, there is a better regular expression that will catch expression that were not included in the sample data.
Set "Find what" to
<a .*?href="#" .*?>(.*?)</a>
This will match lines where there are clauses after the
href="#"
(and before the first matching>
).Note:
It will fail to work correctly if there are any
>
s in the value field of a subsequent clause (before the>
matching<a
)Further reading