在Android中查找和替换字符串

3
myString = "my name=\"ppshein\""

在Android中,如何从上述字符串中删除“=\"ppshein\"”?
5个回答

10
你可以使用这种方式删除字符串:
string.replace("=\"ppshein\"", "");

string.replace("" with \"", ""); - marsbear

2
myString.replace("=\"ppshein\"", "");

1
假设您有一个名为myString的字符串,并且您想要一个新的字符串,其中所有出现的="ppshein"都被删除,请尝试:
String newString = myString.replace("=\"ppshein\"", "")

1
首先,上面的字符串无法编译。你需要这样写:myString = "my name=\"ppshein\"" 其次,使用:myString = myString.replace("=\"ppshein\"", "");

0
myString = myString.replaceAll("StringToReplace", "");

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接