有一个字符串String str = test/123123123/123,bucy/12346546/6980,andy/456345/1235;
我现在需要提取其中的字符串 test fancy andy,不要逗号,不要斜杠
把提取出来的字符串存在数组中 a[0]="test"; a[1]="fancy"; a[2]="andy";
str这个字符串中可能含有很多子字符串 不一定只有三个
谢谢帮助~~

解决方案 »

  1.   

    String str = "test/123123123/123,bucy/12346546/6980,andy/456345/1235";
      

  2.   


    不要数字 
    a[3] = andy
    打错了
      

  3.   

    把提取出来的字符串存在数组中 a[0]="test"; a[1]="bucy"; a[2]="andy";
    不要数字 斜杠 逗号 只要字符串中的英文字符
    比较着急 谢谢
      

  4.   


        public static void main(String[] args)
        {
            String str = "test/123123123/123,bucy/12346546/6980,andy/456345/1235";
            String[] temp = str.split(",");
            for(int i = 0; i < temp.length; i++)
            {
                temp[i] = temp[i].replaceAll("/|[0-9]", "");
            }
            System.out.println(Arrays.toString(temp));    }
      

  5.   


    String reg = "[a-z]+(?=/\\d+/\\d+)";
    String str = "test/123123123/123,bucy/12346546/6980,andy/456345/1235"; Pattern p = Pattern.compile(reg);
    Matcher m = p.matcher(str);
    while(m.find()){
    System.out.println(m.group());
    }仅供参考,
    楼主还是仔细看看1楼的说明吧