正则表达式判断是否包含一个字符串

用java正则表达式检测字符串中含有某字符方法:

public class Test {
 
    public static void main(String[] args) {
        String str="Hello World";  //待判断的字符串
        String reg=".*ll.*";  //判断字符串中是否含有ll
        System.out.println(str.matches(reg));
    }
 
}

猜你喜欢

转载自blog.csdn.net/qq_29373285/article/details/81613209