asp.net regex to find anchor tags and replace their url
Posted
by ace
on Stack Overflow
See other posts from Stack Overflow
or by ace
Published on 2010-05-13T21:29:08Z
Indexed on
2010/05/13
21:34 UTC
Read the original article
Hit count: 257
Hi -i'm trying to find all the anchor tags and appending the href value with a variable. for example
<a href="/page.aspx">link</a> will become <a href="/page.aspx?id=2">
<A hRef='http://www.google.com'><img src='pic.jpg'></a> will become <A hRef='http://www.google.com?id=2'><img src='pic.jpg'></a>
I'm able to match all the anchor tags and href values using regex, then i manually replace the values using string.replace, however i dont think its the efficient way to do this. Is there a solution where i can use something like regex.replace(html,newurlvalue)
© Stack Overflow or respective owner