【发布时间】:2016-02-01 08:43:20
【问题描述】:
我想做以下 HttpResponse 的子字符串。
true#696.887#Nirmal Patel
这是字符串,我只想要整个字符串中的Nirmal patel。
【问题讨论】:
-
参考这些链接javatpoint.com/substring
我想做以下 HttpResponse 的子字符串。
true#696.887#Nirmal Patel
这是字符串,我只想要整个字符串中的Nirmal patel。
【问题讨论】:
你可以这样做,
String yourString = yourResponse.substring(yourResponse.lastIndexOf('#') + 1);
【讨论】:
yourResponse.substring(yourResponse.indexOf('#') + 1,yourResponse.lastIndexOf('#') );
首先使用lastIndexOf方法
int index = YOUR_RESPONSE.lastIndexOf("#");
比使用subString 方法
YOUR_RESPONSE.subString((index+1),YOUR_RESPONSE.length());
【讨论】:
String substring= httpresponse.substring(httpresponse.lastIndexOf('#')+1,httpresponse.length());
【讨论】: