gpt4 book ai didi

android - 从字符串中提取子字符串

转载 作者:IT老高 更新时间:2023-10-28 13:16:52 27 4
gpt4 key购买 nike

从android中的字符串中提取子字符串的最佳方法是什么?

最佳答案

如果你知道开始和结束索引,你可以使用

String substr=mysourcestring.substring(startIndex,endIndex);

如果您想从特定索引获取子字符串直到结束,您可以使用:

String substr=mysourcestring.substring(startIndex);

如果您想从特定字符获取子字符串直到结束,您可以使用:

String substr=mysourcestring.substring(mysourcestring.indexOf("characterValue"));

如果您想在 特定字符之后获取子字符串,请将该数字添加到 .indexOf(char):

String substr=mysourcestring.substring(mysourcestring.indexOf("characterValue") + 1);

关于android - 从字符串中提取子字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5414657/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com