I have the following scenario, I need to change,
<a href="ab/xyz" onclick="ab/123"></a>
to
<a href="pq/xyz" onclick="pq/123"></a>
basically replace "ab" with "pq", whenever "ab" appears in attribute values of a html tag
I wrote the following regex,
(<[^>]+)((=")(ab)([^>/"]*"))+([^>].*>)
and I am doing replaceAll
if(matcher.find())
matcher.ReplaceAll($1$3pq$4$5)
The above code only replaces one attribute value per tag even though I have repetition operator in my regex and I am doing ReplaceAll
If I change the "if" condition to while loop, then it changes all attributes, basically 1 attribute per iteration
Is there a way to just replace all matches in all attribute values without a loop?
Solution: A dumb regex is doing the trick even without repetition operator. Problem was I was matching the entire tag.