我想用这个字符串中的“th”替换所有“td”
String head = "<tr>\n<td> </td>\n<td> </td>\n<td>Libelle</td>\n"
+ "<td>Nom Table</td>\n<td>Groupe</td>\n<td> </td>\n</tr>\n"
我尝试使用:
head.replace("<td>", "<th>");
head.replace("</td>", "</th>");
但它不起作用。
你能帮帮我吗?
最佳答案
String.replace(..)
将返回结果字符串,因此您需要将其重新设置
head = head.replace("<td>", "<th>");
head = head.replace("</td>", "</th>");
关于java - 用java字符串中的th替换所有td的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44967456/