62,623
社区成员
发帖
与我相关
我的任务
分享
Pattern p = Pattern.compile("channelid=\\d{5}");
Matcher m =p.matcher(你的字符串变量);
if (m.find()) {
System.out.println(m.group());
}
public class Test{
public void ch(String str){
int index = str.indexOf("channelid=");
String str1 = str.substring(index+10,index+15);
System.out.println(str1);
}
public static void main(String[] args) {
String str1 = "dsaf3d&channelid=34567&dsfghh3 ";
String str2 = "channelid=87654&sdf452 ";
String str3 = "channelid=76543&channelid=76543 ";
new Test().ch(str3);
}
}