package cn.check.com; public class RegexDemo { public static void main(String[] args) { // TODO Auto-generated method stub String s = "aa,bb,cc"; String[] sp = s.split(",");// 进行分割 // 遍历 for (int x = 0; x < sp.length; x++) { System.out.println(sp[x]); } System.out.println("-------------------------------"); String s1 = "aa.bb.cc"; String[] sp1 = s1.split("\.");// sp1接收数组 // 遍历 for (int x = 0; x < sp1.length; x++) { System.out.println(sp1[x]); } System.out.println("---------------------------"); String s2 = "aa bb cc"; String[] sp2 = s2.split(" +");// 空格+进行分割,不限空格大小 // 遍历 for (int x = 0; x < sp2.length; x++) { System.out.println(sp2[x]); } System.out.println("----------------------------"); // 硬盘上的路径 String s3 = "H:\kinggsoft\kduu_ba"; String[] sp3 = s3.split("\\");// 一个需要两个\来分割 所以需要四个// 遍历 for (int x = 0; x < sp3.length; x++) { System.out.println(sp3[x]); } } }