如下
str='http://192.168.18.3/xxqp/carpart/img_deal/upImg/bgMid_1.jpg'
如何匹配到左后一个/后面的字符串
这里为bgMid_1.jpg

解决方案 »

  1.   

    这个不用正则好像更方便点
    package test;
    public class a {
        public static void main(String[] args) {
            String str =
                    "http://192.168.18.3/xxqp/carpart/img_deal/upImg/bgMid_1.jpg";
            System.out.println(str.substring(str.lastIndexOf("/")+1));
        }
    }
      

  2.   

    Pattern p=Pattern.compile("^.*/(.+)$");
    String str="http://192.168.18.3/xxqp/carpart/img_deal/upImg/bgMid_1.jpg";
    Matcher m = p.matcher(str);
    if(m.matches()){
    System.out.println(m.group(1));
    }不过还是用substring更好