I have a scenario where I need to inject some style attributes into a href.
Example. I need to turn this:
<a href="https://google.com">Google</a>
Into this:
<a href="https://google.com" style="color:blue">Google</a>
I need to select the area between the closing quote of the link, and the closing bracket of the <a>
In the above example it's: style="color:blue"
or before the attribute is inserted, simply that position in the string.
From my searching around and playing in regex101 I can select everything up until the closing quote with something like this:
a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1
but I need the inverse of that, I need to select everything from the quote until the closing bracket >
before Google</a>
to inject the attributes.
Unfortunately regex is something I only get to play with infrequently so hoping someone could give me a hand. Thanks.