public class TestCode {
    public static void main(String[] args) {
        String str ="232ljsfsf.sdfl23.ljsdfsdfsdfss.23423.sdfsdfsfd";
        //获得第一个点的位置
        int index=str.indexOf(".");
        System.out.println(index);
        //根据第一个点的位置 获得第二个点的位置
        index=str.indexOf(".", index+1);
        //根据第二个点的位置,截取 字符串。得到结果 result
        String result=str.substring(index);
        //输出结果
        System.out.println(result);
    }

}

取出倒数第三个“-”前面的内容

public class subString {
    public static void main(String[] args) {
        String b = "/dota-2/talent/arc-warden-20-2-38";
        String subStringB = b.substring(b.lastIndexOf("/")+1);
        int index=subStringB.lastIndexOf("-");
        index=subStringB.lastIndexOf("-", index-1);
        index=subStringB.lastIndexOf("-",index-1);
        System.out.println(subStringB.substring(0,index));
    }

}

 

相关文章:

  • 2021-12-29
  • 2021-11-27
  • 2021-11-13
  • 2022-02-09
  • 2021-05-26
  • 2021-11-17
猜你喜欢
  • 2021-05-31
  • 2021-11-27
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案