Reputation: 43169
I'm parsing remote sites. They contain keywords which are being replaced with the correct values. My problem arises when I want to parse links, like so:
<a href="{_SOMEKEYWORD_}">somestupidtext</a>
SOMEKEYWORD contains an url (i.e. http://www.stackoverflow.com) but there is always a forward slash occurring, like so:
<a href="/{_SOMEKEYWORD_}">somestupidtext</a>
This obviously breaks all the links. I thought of a regex but am very open to better(?) solutions.
Upvotes: 0
Views: 150
Reputation: 36512
You might also be able to get away with a simple string replace if the slash is the only thing you want to remove and it always occurs immediately after the href
:
C#:
string url = "<a href=\"/{_SOMEKEYWORD_}\">somestupidtext</a>";
url = String.Replace("href=\"/", "href=\"");
Upvotes: 1