使用split函数拆分字符串但没有获得所需的结果

时间:2017-10-31 05:58:26

标签: java split

想分割字符串

    String vv = "class="fcg">1.6M";
    String[] breakvv = vv.split(">");
    String breakvv0 = parts[0]; 
    String breakvv1 = parts[1]; 
    System.out.println(breakvv0);
    System.out.println(breakvv1);   

我得到的输出是breakvv0 = an和breakvv1 = class =" fcg"> 1.6M

2 个答案:

答案 0 :(得分:0)

    String vv = "class=\"fcg\">1.6M";
    String[] breakvv = vv.split(">");
    String breakvv0 = breakvv[0]; 
    String breakvv1 = breakvv[1]; 
    System.out.println(breakvv0);
    System.out.println(breakvv1); 

答案 1 :(得分:0)

public static void main(String args[]) {
        String vv = "class=\"fcg\">1.6M";
        String[] breakvv = vv.split(">");
        String breakvv0 = breakvv[0]; 
        String breakvv1 = breakvv[1]; 
        System.out.println(breakvv0);
        System.out.println(breakvv1); 
    }
}