简体   繁体   中英

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 ?

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

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

or

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

字符串是不可变的,将结果分配回texte

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

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

should do the trick

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM