java正则表达式练习题目

使用方法

简单使用
		String str="35987.75";//要匹配的字符串
        String pattern="\\d";
        boolean matches = Pattern.matches(pattern, str);
        System.out.println(matches);
较多使用
		String str="35987.75";//要匹配的字符串
        String pattern="\\d";
        Pattern r=Pattern.compile(pattern);//创建pattern对象
        Matcher matcher = r.matcher(str);//创建matcher对象
        //然后对matcher进行操作

练习

  1. 题目一。请使用正则表达式来解决。

2.题目二

猜你喜欢

转载自blog.csdn.net/qq_43179428/article/details/108945167