I am trying to match an attribute to I can do a search/replace. I am having trouble though because it is matching beyond the quotes of the attribute I want. For example, I want to remove xref="..." from here:
<a href="page.ashx" xref="somethingelse" title="something" class="image">
But when I do a RegEx like this: xref=\".*\", then it selects the attributes xref, title, AND class. How do I tell it to only select the xref attribute?
I strongly suggest using something other than regex for modifying markup, however, this should work:
xref="[^"]*"
Use the non-greedy version: \".*?\"
.*
is greedy selects as much as possible. By adding a ?
to it becomes less greedy selecting just as much as needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With