Hello
I want to do a thing that looks very easy to do but because it needs Regex, I can't manage to do it.
I've got a HTML code in a string that contains links in this format:
Code:
<a href="/dir1/file">
Note: number of directories is not always just 1, it can be more.
and I want my program to change all occurences of links in a format like above to a format like that(it's just adding ".html"):
Code:
<a href="/dir1/file.html">
It would be very easy to do if only String.Replace() allowed me to use wildcards. If it did, it would be probably as easy as that:
Code:
str = str.Replace("a href=\"*\">", "a href=\"*.html\">"
I tried to use Regex, doing it this way:
Code:
str = Regex.Replace(str, "<a href=\"(?<link>[a-zA-Z0-9_/-])\"", "<a href=${link}" + ".html\"");
but it doesn't work.


Any help will be very appreciated.