广西住房城乡和建设厅网站首页,后端低代码平台,崇卅市网站建设,wordpress 更改密码重复匹配
* 可以匹配任意个字符#xff0c;包括0个字符。 可以匹配至少一个字符。? 可以匹配0个或一个字符。{n} 可以精确指定 n 个字符。{n,m} 可以精确匹配 n-m 个字符。你可以是 0 。
匹配任意个字符
匹配 D 开头#xff0c;后面是任意数字的字符#xff0c; String …重复匹配
* 可以匹配任意个字符包括0个字符。 可以匹配至少一个字符。? 可以匹配0个或一个字符。{n} 可以精确指定 n 个字符。{n,m} 可以精确匹配 n-m 个字符。你可以是 0 。
匹配任意个字符
匹配 D 开头后面是任意数字的字符 String regexU1 D\\d*;System.out.println(DD.matches(regexU1));// falseSystem.out.println(D1.matches(regexU1));// trueSystem.out.println(D202.matches(regexU1));// trueSystem.out.println(D88888888.matches(regexU1));// true匹配至少一个字符
匹配 D 开头后面至少是一位数字的字符 String regexU2 D\\d;System.out.println(D.matches(regexU2));// falseSystem.out.println(D1.matches(regexU2));// trueSystem.out.println(D202.matches(regexU2));// trueSystem.out.println(D88888888.matches(regexU2));// true匹配 0 个或一个字符
匹配 D 开头后面是 0个或一个数字的字符 String regexU3 D\\d?;System.out.println(D.matches(regexU3));// trueSystem.out.println(D1.matches(regexU3));// trueSystem.out.println(D22.matches(regexU3));// falseSystem.out.println(D88888888.matches(regexU3));// false匹配 n 个字符
匹配 D 开头后面 3 个数字的字符 String regexU4 D\\d{3};System.out.println(D.matches(regexU4));// falseSystem.out.println(D1.matches(regexU4));// falseSystem.out.println(D22.matches(regexU4));// falseSystem.out.println(D301.matches(regexU4));// trueSystem.out.println(D3004.matches(regexU4));// false匹配 n-m 个字符
匹配 D 开头后面是 3-5 位数字的字符 String regexU5 D\\d{3,5};System.out.println(D.matches(regexU5));// falseSystem.out.println(D1.matches(regexU5));// falseSystem.out.println(D22.matches(regexU5));// falseSystem.out.println(D333.matches(regexU5));// trueSystem.out.println(D4000.matches(regexU5));// trueSystem.out.println(D55555.matches(regexU5));// trueSystem.out.println(D666666.matches(regexU5));// false