public static void main(String[] args) {
  String str = "四川省成都市";
  if(str.indexOf("省")!=-1){
    System.out.println("存在");
  }else{
    System.out.println("不存在!");
  }
}

 

String address = "四川省—成都市";

String province = b.substring(0, b.indexOf("—"));

String city = b.substring(b.indexOf("—")+1);

System.out.println(province);//四川省

System.out.println(city);//成都市

 

也可以截取

public static void main(String[] args) {
  String str = "四川省成都市";
  String s = str.substring(0,3);
  if("四川省".equals(s)){
    System.out.println("存在");
  }else{
    System.out.println("不存在");
  }
}

 

 

public static void main(String[] args) {
String str = "中国银保监会关于华安财产保险股份有限公司机动车出境综合商业保险条款和费率的批复";
String s = str.substring(str.indexOf("司")+1,str.indexOf("条"));
System.out.println(s);
}

相关文章:

  • 2022-02-06
  • 2022-12-23
  • 2023-03-11
  • 2021-10-01
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
  • 2022-01-07
相关资源
相似解决方案