split()切割?问号

    // split()中引入了正则 所以切割 ? 需要先转义
    public static void main(String[] args) {
        String url = "http://172.0.0.1/zhangsan.jpg?age=20";
        String[] split = url.split("\\?");
        System.out.println("split = " + split[0]);//split = http://172.0.0.1/zhangsan.jpg
    }

 

posted @ 2020-09-01 17:32  SimonShixinlong  阅读(2802)  评论(0)    收藏  举报