0

Is there a way, using java's standard library to replace characters like:

" with '"' and &# 39; (i put a space so the site doesn't change it) with ''' in a string?

For example, change from:

String message = ""This &# 39;is&# 39; a test&quote";

to:

message = "\"This \'is\' a test\"";

I'm not talking about using regular expressions or searching and replacing. I want it to cover all HTML characters. I think some text panes and things like that are able to do it. Anyone know which one and how I can use it's functions? Anyone other ideas?

Edited by TheWhite: n/a

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by JamesCherrill
0

Hmm... Why can't you use regex? What is the problem with it?

String str = "&quote;This is just something&# 39;";
str = str.replaceAll(/&quote;/, "\"");
 // or
str = str.replaceAll(/\&# 39;/, "\'"); // shouldn't have space as you said

And if you want it to cover all HTML code, you may implement a class that handle this for you. Each number, you will have to do the replacement individually.

Edited by Taywin: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.