/*
* 1>matchers()字符串匹配
* 2>replaceAll()替换字符
* 3>split()拆分字符串
*/
package com.pattern;
public class string {
public static void main(String[] args){
//1>matchers()字符串匹配
String s1 = "wewe中国人";
Boolean b = s1.matches("\\w*中国人");
System.out.println(b);
//2>replaceAll()替换字符
String s2 = "李二李三李四李五";
String result = s2.replaceAll("李", "张");
System.out.println(result);
//3>split()拆分字符串
String s3 = "中国人|龙的传人/李小龙";
String arr[] = s3.split("\\||\\/");
for(int i=0;i<arr.length;i++){
System.out.println(arr[i]);
}
}
}
java String类对正则表达式的支持