I have a the following path which I need to convert to URL.
string path = @"\\TestServer\User_Attachments$\Data\Reference\Input\Test.png";
I'm trying to replace the replace the special chars in this string. So
\\ will become//with anhttpsadded at the front i.e.https://`\will become/User_Attachments$will becomeUser_Attachments
The final string should look like
string url = "https://TestServer/User_Attachments/Data/Reference/Input/Test.png"
To achieve this I've come up with the following regex
string pattern = @"^(.{2})|(\\{1})|(\${1})";
I then match using the Matches() method as:
var match = Regex.Matches(path, pattern);
My question is how can I check to see if the match is success and replace the appropriate value at the appropriate group and have a final url string as I mentioned above.
Here is the link to the regex