Regular Expression for adding an attribute inside an anchor tag

I'm using the WordPress plugin Search Regex. My goal is to add rel=sponsored attributes to all links with a certain domain name and pattern. The plugin has 2 fields (global search and global replacement pattern).

Search should be for:

<a href="">

Replace with:

<a href="" rel="sponsored">

anystringhere is always different and can contain anything. So, between <a href=" and the next " is always something different. Basically the whole anchor tag shouldn't be touched, except adding the sponsored attribute.

Could someone provide me with the correct regex for the search field and the replacement field?



Is it possible to add a condition? Some anchor tags already have rel="sponsored" attribute inside and I'd like to skip these.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum