-4

I have a string in java that looks like this "&#039;&#039;&#039;&#039;&lt;&gt;!@#$%^&amp", this was escaped in javascript. I need to obtain the original string before escaping the special characters, which is "''''<>!@#$%^&*()".

Matt Ball
  • 344,413
  • 96
  • 627
  • 693

3 Answers3

1

You can use StringEscapeUtils.unescapeHtml4 for this.

For example, the string "&lt;Fran&ccedil;ais&gt;" will become "<Français>"

pascalhein
  • 5,530
  • 4
  • 30
  • 41
0

You need to know how it was encoded to reverse it.

If it was URL encoded (which looks likely) then Java has a built in URLDecoder class.

URLDecoder.decode(message, encoding);
Tim B
  • 39,784
  • 16
  • 75
  • 127
0

Apache Commons provides utilities for this.

org.apache.commons.lang.StringEscapeUtils.unescapeHtml(String string) should be what you want.

Check out the API here

Dragondraikk
  • 1,658
  • 11
  • 21