6.第五节demo5

    xiaoxiao2024-12-27  65

    package com.zzh.day1; public class demo5 { public static void main(String[] args){ //POSIX style;img/POSIXStyle.png System.out.println("a".matches("\\p{Lower}")); /* * 边界匹配,img/BoundaryMatcher.png * */ System.out.println("hello sir".matches("^h.*"));//^ the beginning of a line System.out.println("hello sir".matches(".*ir$"));//$ the end of a line System.out.println("hello sir".matches("^h[a-z]{4}\\b.*"));//\b a word boundary System.out.println("hellosir".matches("^h[a-z]{4}\\B.*")); /* * 空白行 * */ System.out.println(" \n".matches("^\\s&&[^\\n].*\\n$")); } }

    输出结果: 1 true 2 true 3 true 4 true 5 true 6 true

    {Lower}表示小写

    最新回复(0)