0

I am supposed to get : Relevance in a request as a parameter but I am getting & #x3a; Relevance. Instead of a colon(:) I am getting hex code of which is &#x3a ;

Here this Relevance is a varying parameter. So now how can I convert only hex code in a string to its ASCII and leave the other characters as is?

We use java.

Prajwal
  • 246
  • 1
  • 5
  • 16
pa_One
  • 35
  • 1
  • 2
  • 11
  • `String s = yourString.replace("& #x3a;", ":")`? – Lino Mar 15 '19 at 11:18
  • Are you _really_ getting `& #x3a;`, i.e. with the space in between? Basically that "hex code" is called a html entity so what you want is to convert those to characters: https://stackoverflow.com/questions/994331/java-how-to-unescape-html-character-entities-in-java – Thomas Mar 15 '19 at 11:23
  • @Pavan yvs Can't you substring the string and `& #x3a;` replaced with `:` ? – Rmahajan Mar 15 '19 at 11:35
  • @Ros5292 Thought of replacing it with : but the thing is somewhere in the application we may be getting characters other than :. So it will be better if we can be able to replace only the hexcode. I wonder if that is possible. – pa_One Mar 15 '19 at 11:52
  • ya @Thomas, it is without space. but if i type : while posting the question it is automatically converted to : . Hence I posted it that way. – pa_One Mar 15 '19 at 11:59
  • Well, you could use the inline code tags (code between 2 ticks: ` code ` - just without leading or trailing whitespace :) ), e.g. `:` :) – Thomas Mar 15 '19 at 12:02
  • Have a look at the link I've posted. That question should cover your needs. – Thomas Mar 15 '19 at 12:05

0 Answers0