0

I have 2 html tags. But only the first tag has these 2 words: elementor and widget. So I want to find all html tags that has those 2 words, and if finds, delete the entire tag.

<p class="jopp">.elementor-widget-text-editor: nu (.Elementor-drop-cap-view-default) .Elementor  s  50px} .Elementor-widget-text-editor .Elementor-drop-cap-letter {display: inline-block}</p>

<p class="jopp">Sunt fascinat de cazuri legale despre artă.</p>

I try to make a formula regex, but doesn't work:

(<p class="jopp>).*\K(?:\h+(elementor|widget))(?=.*p>)

2 Answers 2

0

Using Notepad++:

  • Ctrl+H
  • Find what: <p (?=(?:(?!</p>).)*?elementor)(?=(?:(?!</p>).)*?widget).+?</p>\R?
  • Replace with: LEAVE EMPTY
  • TICK Wrap around
  • SELECT Regular expression
  • UNTICK . matches newline
  • Replace all

Explanation:

<p                                  # open tag
(?=(?:(?!</p>).)*?elementor)        # positive lookahead, make sure we have "elementor" somewhere after but not preceeded by "</p>"
(?=(?:(?!</p>).)*?widget)           # positive lookahead, make sure we have "widget" somewhere after but not preceeded by "</p>"
.+?                                 # 1 or more any character
</p>                                # close tag
\R?                                 # optional any kind of linebreak

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

0

I Find myself an answer

Use the following:

  • Ctrl+H
  • Find what: (<p class="jopp">).*(\b(elementor|widget)\b.*).*(</p>)
  • Replace with: LEAVE EMPTY
  • CHECK Match case
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all
2
  • Be aware that will match when there is only elementor or widget
    – Toto
    Commented Sep 29, 2022 at 16:52
  • yes, I see now. Anyway, is an alternative :) Commented Sep 29, 2022 at 18:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .