Regex: Remove duplicate html tags in multiple files [duplicate]

Use this:

  • Ctrl+H
  • Find what: (^<link.+)\R(?=[\s\S]*\1)
  • Replace with: LEAVE EMPTY
  • CHECK Match case
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

(^<link.+)      # group 1, link tag at the beginning of line
\R              # any kind of linebreak
(?=             # positive lookahead, make sure we have after:
    [\s\S]*         # 0 or more any character
    \1              # backreference to group 1
)               # end lookahead

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here