Java,Pattern.compile 用正则表达式解析字符串

package com.company;


import java.util.regex.Pattern;

/**
 * @Author
 * @Date 2020/4/26 21:49
 * @Version 1.0
 * @Desc
 */
public class Main8 {

    private static final Pattern splitter1 = Pattern.compile("_");
    private static final Pattern splitter2 = Pattern.compile("[a-zA-Z]");
    public static void main(String[] args) {
        System.out.println(1234);
        String str1 = "a_v_cd_123";
        String[] strArr1 = splitter1.split(str1);
        System.out.println(strArr1);


        String str2 = "12a23d7Dtt5";
        String[] strArr2 = splitter2.split(str2);
        System.out.println(strArr2);
    }
}

Java,Pattern.compile 用正则表达式解析字符串_第1张图片

 

你可能感兴趣的:(Java,Java,Pattern,compile,正则表达式,解析)