Answer the question
In order to leave comments, you need to log in
How to remove a link with an exception?
Hello. Guys tell me how to add an exception to the regular expression.
I need to remove links, but leave the anchor, for example:
1) <a href="https://qna.habr.com/">Некая ссылка 1</a>
2) <strong><a href="#">Некая ссылка 2</a></strong>
3) <strong><a class="_5ayv _qdx" href="/hashtag/творческие"><span class="_5aw4 _qdz">#</span><span class="_5ayu">творческие</span></a>
Должно в исходнике получиться так:
1) Некая ссылка 1
2) Некая ссылка 2
3) творческие
---
т е ссылки вырезали, остались только анкоры...
<a class="mylinks" href="https://qna.habr.com/">моя ссылка 1</a>
не трогало совсем
<a (?!mylinks) href="(.*?)">.*?</a>
Answer the question
In order to leave comments, you need to log in
If in an element with a strict order (the class comes first), You can do thisclass="mylinks"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question