3
In a field I need to replace two words with any other two.
Example: Mr(a) v1, the value of your invoice is real v2.
As it should be:
Mr(a) Joao, the value of your invoice is 10,00 real.
So I have the following method below.
String mensagemI = txtMensagem.getText();
String var1 = txtVariavel1.getText();
String var2 = txtVariavel2.getText();
String var3 = txtVariavel3.getText();
String mensagemF = mensagemI.replaceAll("v1", var1);
System.out.println(mensagemF);
But in this way, I can change only one word of the sentence, in this case v1.
Is there any other method where I can change two words in one sentence?
Thank you.
Why not call the replaceAll 2 times ?
– Felipe
Felipe, I tried, but it’s a mistake.
– Wagner Fillio
can post the most recent and complete code ? ( if this is the most recent note that var1 is being modified 3 times )
– Felipe
I’m sorry, fixed. And this is the latest code
– Wagner Fillio