0

I have the following code which is changing the text I am inputting to UPPERCASE

if(WrtMsg.isDisplayable()== true); { //System.out.println(test.toString().toUpperCase()); RecView.setText(test.toString().toUpperCase()); } 

Now I want special characters like asterix (*) to be changes as text. Example * to ATX ... So the output will be displayed as ATX.

WrtMsg is the jtextarea of text input and RecView is the jtextarea where the output is showing.

Any help please? Thanks.

5 Answers 5

1

Just use the replaceAll method of the String class. something.replaceAll(Pattern.quote("*"), "ATX").

Sign up to request clarification or add additional context in comments.

1 Comment

I think you mean Pattern.quote(...)
1
if(wrtMsg.getText().contains("*")) { RecView.setText("ATX"); } 

Comments

1

Have you considered manually changing it in code? You could create a method like this:

private String charToText(String character) { character = character.replace("*", "ATX") // and so forth... return character; } 

1 Comment

Sorry, forgot for a sec. Fixed now.
0

You should use the replace method of the string object

test.toString().toUpperCase().replace("*", "ATX") 

Comments

0
RecView.setText(wrtMsg.getText().replace("*", "ATX")); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.