Karla Basco Karla Basco - 6 months ago 14
Vb.net Question

Regular expressions on converting a URL hex code into character

I have this sample URL with hex code:

http%3a%2f%2fwww.pmi.com%2feng%2fcareers%2fpages%2fjob_details.aspx%3fjlang%3deng%26jcod%3dUS-02073


I want to formulate a regular expression on converting those hex code into character entities.

%2f => /


Is it possible to have transform the link into this using reg expression?

from:

http%3a%2f%2fwww.pmi.com%2feng%2fcareers%2fpages%2fjob_details.aspx%3fjlang%3deng%26jcod%3dUS-02073


output:

http://www.pmi.com/eng/careers/pages/job_details.aspx?jlang=eng&jcod=US-02073


Like the function of this site: http://www.url-encode-decode.com/?_ga=1.244038725.1379940417.1464232194

Answer

Easier done in C# than Regex:

using System.Net;

string URL = "http%3a%2f%2fwww.pmi.com%2feng%2fcareers%2fpages%2fjob_details.aspx%3fjlang%3deng%26jcod%3dUS-02073";
string DecodedURL = WebUtility.UrlDecode(URL);
Comments