zoukankan      html  css  js  c++  java
  • java 判断字符串是否包含特定的字符(截取指定字符前面或者后面的值)

    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);
    }

    qq 891451702
  • 相关阅读:
    django基础之ORM基础知识
    Centos7 搭建sonarQube
    centos7安装部署SVN
    centos7.5 SVN 搭建
    centos 7 部署 zookeeper
    centos7 发送邮件
    Centos7安装配置Gitlab-CE
    openldap 双主模式部署
    K8s一键安装
    ELK实战部署
  • 原文地址:https://www.cnblogs.com/duoyan/p/11793160.html
Copyright © 2011-2022 走看看