Gerald Tan
Gerald Tan

Reputation: 91

Convert regex to special characters

I have a url that would contain something like this:

%5B%7B%22field%22%3A%22Site+Code%22%2C%22value%22%3A%2245%22%7D%2C%7B%22field%22%3A%22textarea-1%22%2C%22value%22%3A%2212%22%7D%2C%7B%22field%22%3A%22Serial+%23%22%2C%22value%22%3A%2223%22%7D%5D%26SiteID%3D1%3B

I'm taking in the url as a string and would like to convert all the regex to special characters. Is there any way to do this? The regex is not limited to just this. I need to take into account all instances in which regex could show up in the string, and replace it with the corresponding special character.

Upvotes: 0

Views: 95

Answers (1)

Jacob Boertjes
Jacob Boertjes

Reputation: 971

Since there are so many special characters you will need to account for, and in regex you will have to replace each one seperately, I do not think that regex is the best solution to this issue. A better solution is available here: How to do URL decoding in Java?

Upvotes: 2

Related Questions