【发布时间】:2016-03-10 01:29:17
【问题描述】:
下面是一个字符串,我想从中获取粗体 id。
String s = "> Index1 is: 261 String is: href: <a href="https://www.clover.com/v3/merchants/4B8BF3Y5NJH7P/orders/K0AH5696MRG6J?access_token=4ffcfacefd3b2e9611a448da68fff91f">https://www.clover.com/v3/merchants/4B8BF3Y5NJH7P/orders/K0AH5696MRG6J?access_token=4ffcfacefd3b2e9611a448da68fff91f</a>, id: **K0AH5696MRG6J**, currency: USD, title: Greta , note: This is test ,";
int ind = s.indexOf("id:");
s = s.substring(ind,s.indexOf(","));
它给出了一个超出范围的错误索引。
我知道有错误是因为 substring(int,int) 中的第二个参数值不正确。
我正在尝试获取id: 和, 之间的子字符串。
任何帮助
【问题讨论】: