meee meeee
meee meeee

Reputation: 211

how do I to replace a detected String in Java

I'm trying to parse some extracted data. So, I can't find how do I to replace a detected String in Java?

I've tried this, but it doesn't work for me :

texte.replace("gras", "bold");

Any help please ?

Upvotes: 0

Views: 95

Answers (3)

user2742438
user2742438

Reputation:

Strings are immutable, calling a method on a string will never change it.

texte = texte.replace("gras", "bold");

should do the trick

Upvotes: 0

Konstantin
Konstantin

Reputation: 3294

strings are immutable assign result back to texte

Upvotes: 0

jlordo
jlordo

Reputation: 37833

Strings are immutable. You need to assign the returned string to a string variable. E.g.

texte = texte.replace("gras", "bold");

or

String replaced = texte.replace("gras", "bold");

Upvotes: 4

Related Questions