C# Regex replace url
Posted
by Martijn
on Stack Overflow
See other posts from Stack Overflow
or by Martijn
Published on 2010-05-31T18:05:48Z
Indexed on
2010/05/31
18:13 UTC
Read the original article
Hit count: 555
I have a bunch of links in a document which has to be replaced by a javascript call. All the links looks the same:
<a href="http://domain/ViewDocument.aspx?id=3D1&doc=form" target="_blank">Document naam 1</a>
<a href="http://domain/ViewDocument.aspx?id=3D2&doc=form" target="_blank">Document naam 2</a>
<a href="http://domain/ViewDocument.aspx?id=3D3&doc=form" target="_blank">Document naam 3</a>
Now I want all this links to be replaced to:
<a href="javascript:loadDocument('1','form')">Document naam 1</a>
<a href="javascript:loadDocument('2','form')">Document naam 2</a>
<a href="javascript:loadDocument('3','form')">Document naam 3</a>
So the Id=3D in the url is the first parameter in the function and the doc parameter is the second parameter in the function call.
I want to do this using Regex because I think this is the quickest way. But the problem is my regex knowledge is too limited
© Stack Overflow or respective owner