当前位置: 首页 > news >正文

杭州企业网站制作哪家好怎么做有声小说网站播音员

杭州企业网站制作哪家好,怎么做有声小说网站播音员,建购物网站需要些什么,wordpress 商品采集正则表达式 1.1 正则表达式的概念及演示 在Java中#xff0c;我们经常需要验证一些字符串#xff0c;例如#xff1a;年龄必须是2位的数字、用户名必须是8位长度而且只能包含大小写字母、数字等。正则表达式就是用来验证各种字符串的规则。它内部描述了一些规则#xff0c…正则表达式 1.1 正则表达式的概念及演示 在Java中我们经常需要验证一些字符串例如年龄必须是2位的数字、用户名必须是8位长度而且只能包含大小写字母、数字等。正则表达式就是用来验证各种字符串的规则。它内部描述了一些规则我们可以验证用户输入的字符串是否匹配这个规则。 先看一个不使用正则表达式验证的例子下面的程序让用户输入一个QQ号码我们要验证 QQ号码必须是5--15位长度 而且必须全部是数字 而且首位不能为0 package com.itheima.a08regexdemo; ​ public class RegexDemo1 {public static void main(String[] args) {/* 假如现在要求校验一个qq号码是否正确。规则:6位及20位之内日不能在开头必须全部是数字。先使用目前所学知识完成校验需求然后体验一下正则表达式检验。*/ ​String qq 1234567890;System.out.println(checkQQ(qq)); ​System.out.println(qq.matches([1-9]\\d{5,19})); ​} ​public static boolean checkQQ(String qq) {//规则:6位及20位之内日不能在开头必须全部是数字 。//核心思想://先把异常数据进行过滤//下面的就是满足要求的数据了。int len qq.length();if (len 6 || len 20) {return false;}//0不能在开头if (qq.startsWith(0)) {return false;}//必须全部是数字for (int i 0; i qq.length(); i) {char c qq.charAt(i);if (c 0 | c 9) {return false;}}return true;} } 使用正则表达式验证 public class Demo {public static void main(String[] args) {String qq 1234567890;System.out.println(qq.matches([1-9]\\d{5,19}));} } 我们接下来就重点学习怎样写正则表达式 1.2 正则表达式-字符类 语法示例 [abc]代表a或者b或者c字符中的一个。 [^abc]代表除a,b,c以外的任何字符。 [a-z]代表a-z的所有小写字符中的一个。 [A-Z]代表A-Z的所有大写字符中的一个。 [0-9]代表0-9之间的某一个数字字符。 [a-zA-Z0-9]代表a-z或者A-Z或者0-9之间的任意一个字符。 [a-dm-p]a 到 d 或 m 到 p之间的任意一个字符。 代码示例 package com.itheima.a08regexdemo; ​ public class RegexDemo2 {public static void main(String[] args) {//public boolean matches(String regex):判断是否与正则表达式匹配匹配返回true// 只能是a b cSystem.out.println(-----------1-------------);System.out.println(a.matches([abc])); // trueSystem.out.println(z.matches([abc])); // false ​// 不能出现a b cSystem.out.println(-----------2-------------);System.out.println(a.matches([^abc])); // falseSystem.out.println(z.matches([^abc])); // trueSystem.out.println(zz.matches([^abc])); //falseSystem.out.println(zz.matches([^abc][^abc])); //true ​// a到zA到Z(包括头尾的范围)System.out.println(-----------3-------------);System.out.println(a.matches([a-zA-z])); // trueSystem.out.println(z.matches([a-zA-z])); // trueSystem.out.println(aa.matches([a-zA-z]));//falseSystem.out.println(zz.matches([a-zA-Z])); //falseSystem.out.println(zz.matches([a-zA-Z][a-zA-Z])); //trueSystem.out.println(0.matches([a-zA-Z]));//falseSystem.out.println(0.matches([a-zA-Z0-9]));//true ​ ​// [a-d[m-p]] a到d或m到pSystem.out.println(-----------4-------------);System.out.println(a.matches([a-d[m-p]]));//trueSystem.out.println(d.matches([a-d[m-p]])); //trueSystem.out.println(m.matches([a-d[m-p]])); //trueSystem.out.println(p.matches([a-d[m-p]])); //trueSystem.out.println(e.matches([a-d[m-p]])); //falseSystem.out.println(0.matches([a-d[m-p]])); //false ​// [a-z[def]] a-z和def的交集。为:defSystem.out.println(----------5------------);System.out.println(a.matches([a-z[def]])); //falseSystem.out.println(d.matches([a-z[def]])); //trueSystem.out.println(0.matches([a-z[def]])); //false ​// [a-z[^bc]] a-z和非bc的交集。(等同于[ad-z])System.out.println(-----------6------------_);System.out.println(a.matches([a-z[^bc]]));//trueSystem.out.println(b.matches([a-z[^bc]])); //falseSystem.out.println(0.matches([a-z[^bc]])); //false ​// [a-z[^m-p]] a到z和除了m到p的交集。(等同于[a-1q-z])System.out.println(-----------7-------------);System.out.println(a.matches([a-z[^m-p]])); //trueSystem.out.println(m.matches([a-z[^m-p]])); //falseSystem.out.println(0.matches([a-z[^m-p]])); //false ​} } ​ 1.3 正则表达式-逻辑运算符 语法示例 并且 | 或者 \ 转义字符 代码示例 public class Demo {public static void main(String[] args) {String str had;//1.要求字符串是小写辅音字符开头后跟adString regex [a-z[^aeiou]]ad;System.out.println(1. str.matches(regex));//2.要求字符串是aeiou中的某个字符开头后跟adregex [a|e|i|o|u]ad;//这种写法相当于regex [aeiou]ad;System.out.println(2. str.matches(regex));} } ​ package com.itheima.a08regexdemo; ​ public class RegexDemo3 {public static void main(String[] args) {// \ 转义字符 改变后面那个字符原本的含义//练习:以字符串的形式打印一个双引号//在Java中表示字符串的开头或者结尾 ​//此时\表示转义字符改变了后面那个双引号原本的含义//把他变成了一个普普通通的双引号而已。System.out.println(\); ​// \表示转义字符//两个\的理解方式前面的\是一个转义字符改变了后面\原本的含义把他变成一个普普通通的\而已。System.out.println(c:Users\\moon\\IdeaProjects\\basic-code\\myapi\\src\\com\\itheima\\a08regexdemo\\RegexDemo1.java); ​ ​ ​ ​} } ​ 1.4 正则表达式-预定义字符 语法示例 . 匹配任何字符。 \d任何数字[0-9]的简写 \D任何非数字[^0-9]的简写 \s 空白字符[ \t\n\x0B\f\r] 的简写 \S 非空白字符[^\s] 的简写 \w单词字符[a-zA-Z_0-9]的简写 \W非单词字符[^\w] 代码示例 public class Demo {public static void main(String[] args) {//.表示任意一个字符System.out.println(你.matches(..)); //falseSystem.out.println(你.matches(.)); //trueSystem.out.println(你a.matches(..));//true ​// \\d 表示任意的一个数字// \\d只能是任意的一位数字// 简单来记:两个\表示一个\System.out.println(a.matches(\\d)); // falseSystem.out.println(3.matches(\\d)); // trueSystem.out.println(333.matches(\\d)); // false ​//\\w只能是一位单词字符[a-zA-Z_0-9]System.out.println(z.matches(\\w)); // trueSystem.out.println(2.matches(\\w)); // trueSystem.out.println(21.matches(\\w)); // falseSystem.out.println(你.matches(\\w));//false ​// 非单词字符System.out.println(你.matches(\\W)); // trueSystem.out.println(---------------------------------------------);// 以上正则匹配只能校验单个字符。 ​ ​// 必须是数字 字母 下划线 至少 6位System.out.println(2442fsfsf.matches(\\w{6,}));//trueSystem.out.println(244f.matches(\\w{6,}));//false ​// 必须是数字和字符 必须是4位System.out.println(23dF.matches([a-zA-Z0-9]{4}));//trueSystem.out.println(23 F.matches([a-zA-Z0-9]{4}));//falseSystem.out.println(23dF.matches([\\w[^_]]{4}));//trueSystem.out.println(23_F.matches([\\w[^_]]{4}));//false} } 1.5 正则表达式-数量词 语法示例 X? : 0次或1次 X* : 0次到多次 X : 1次或多次 X{n} : 恰好n次 X{n,} : 至少n次 X{n,m}: n到m次(n和m都是包含的) 代码示例 public class Demo {public static void main(String[] args) {// 必须是数字 字母 下划线 至少 6位System.out.println(2442fsfsf.matches(\\w{6,}));//trueSystem.out.println(244f.matches(\\w{6,}));//false ​// 必须是数字和字符 必须是4位System.out.println(23dF.matches([a-zA-Z0-9]{4}));//trueSystem.out.println(23 F.matches([a-zA-Z0-9]{4}));//falseSystem.out.println(23dF.matches([\\w[^_]]{4}));//trueSystem.out.println(23_F.matches([\\w[^_]]{4}));//false} } ​ 1.6 正则表达式练习1 需求 请编写正则表达式验证用户输入的手机号码是否满足要求。 请编写正则表达式验证用户输入的邮箱号是否满足要求。 请编写正则表达式验证用户输入的电话号码是否满足要求。 验证手机号码 13112345678 13712345667 13945679027 139456790271 验证座机电话号码 020-2324242 02122442 027-42424 0712-3242434 验证邮箱号码 3232323qq.com zhangsanitcast.cnn dlei0009163.com dlei0009pci.com.cn 代码示例 package com.itheima.a08regexdemo; ​ public class RegexDemo4 {public static void main(String[] args) {/*需求请编写正则表达式验证用户输入的手机号码是否满足要求。请编写正则表达式验证用户输入的邮箱号是否满足要求。请编写正则表达式验证用户输入的电话号码是否满足要求。验证手机号码 13112345678 13712345667 13945679027 139456790271验证座机电话号码 020-2324242 02122442 027-42424 0712-3242434验证邮箱号码 3232323qq.com zhangsanitcast.cnn dlei0009163.com dlei0009pci.com.cn*/ ​//心得://拿着一个正确的数据从左到右依次去写。//13112345678//分成三部分://第一部分:1 表示手机号码只能以1开头//第二部分:[3-9] 表示手机号码第二位只能是3-9之间的//第三部分:\\d{9} 表示任意数字可以出现9次也只能出现9次String regex1 1[3-9]\\d{9};System.out.println(13112345678.matches(regex1));//trueSystem.out.println(13712345667.matches(regex1));//trueSystem.out.println(13945679027.matches(regex1));//trueSystem.out.println(139456790271.matches(regex1));//falseSystem.out.println(-----------------------------------); ​//座机电话号码//020-2324242 02122442 027-42424 0712-3242434//思路://在书写座机号正则的时候需要把正确的数据分为三部分//一:区号\\d{2,3}//     0:表示区号一定是以0开头的//     \\d{2,3}:表示区号从第二位开始可以是任意的数字可以出现2到3次。//二:- ?表示次数日次或一次//三:号码 号码的第一位也不能以日开头从第二位开始可以是任意的数字号码的总长度:5-10位String regex2 0\\d{2,3}-?[1-9]\\d{4,9};System.out.println(020-2324242.matches(regex2));System.out.println(02122442.matches(regex2));System.out.println(027-42424.matches(regex2));System.out.println(0712-3242434.matches(regex2)); ​//邮箱号码//3232323qq.com zhangsanitcast.cnn dlei0009163.com dlei0009pci.com.cn//思路://在书写邮箱号码正则的时候需要把正确的数据分为三部分//第一部分:的左边 \\w//     任意的字母数字下划线至少出现一次就可以了//第二部分: 只能出现一次//第三部分://     3.1         .的左边[\\w[^_]]{2,6}//                 任意的字母加数字总共出现2-6次(此时不能出现下划线)//     3.2         . \\.//     3.3         大写字母小写字母都可以只能出现2-3次[a-zA-Z]{2,3}//     我们可以把3.2和3.3看成一组这一组可以出现1次或者两次String regex3 \\w[\\w[^_]]{2,6}(\\.[a-zA-Z]{2,3}){1,2};System.out.println(3232323qq.com.matches(regex3));System.out.println(zhangsanitcast.cnn.matches(regex3));System.out.println(dlei0009163.com.matches(regex3));System.out.println(dlei0009pci.com.cn.matches(regex3)); ​ ​//24小时的正则表达式String regex4 ([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d;System.out.println(23:11:11.matches(regex4)); ​String regex5 ([01]\\d 2[0-3])(:[0-5]\\d){2};System.out.println(23:11:11.matches(regex5));} } ​ 1.7 正则表达式练习2 需求 请编写正则表达式验证用户名是否满足要求。要求:大小写字母数字下划线一共4-16位 请编写正则表达式验证身份证号码是否满足要求。 简单要求: 18位前17位任意数字最后一位可以是数字可以是大写或小写的x 复杂要求: 按照身份证号码的格式严格要求。 身份证号码: ​ 41080119930228457x ​ 510801197609022309 ​ 15040119810705387X ​ 130133197204039024 ​ 430102197606046442 代码示例 public class RegexDemo5 {public static void main(String[] args) {/*正则表达式练习:需求请编写正则表达式验证用户名是否满足要求。要求:大小写字母数字下划线一共4-16位请编写正则表达式验证身份证号码是否满足要求。简单要求:18位前17位任意数字最后一位可以是数字可以是大写或小写的x复杂要求:按照身份证号码的格式严格要求。 ​身份证号码:41080119930228457x51080119760902230915040119810705387X130133197204039024 I430102197606046442*/ ​//用户名要求:大小写字母数字下划线一共4-16位String regex1 \\w{4,16};System.out.println(zhangsan.matches(regex1));System.out.println(lisi.matches(regex1));System.out.println(wangwu.matches(regex1));System.out.println($123.matches(regex1)); ​ ​//身份证号码的简单校验://18位前17位任意数字最后一位可以是数字可以是大写或小写的xString regex2 [1-9]\\d{16}(\\d|x|x);String regex3 [1-9]\\d{16}[\\dXx];String regex5 [1-9]\\d{16}(\\d(?i)x); ​System.out.println(41080119930228457x.matches(regex3));System.out.println(510801197609022309.matches(regex3));System.out.println(15040119810705387X.matches(regex3));System.out.println(130133197204039024.matches(regex3));System.out.println(430102197606046442.matches(regex3)); ​ ​//忽略大小写的书写方式//在匹配的时候忽略abc的大小写String regex4 a((?i)b)c;System.out.println(------------------------------);System.out.println(abc.matches(regex4));//trueSystem.out.println(ABC.matches(regex4));//falseSystem.out.println(aBc.matches(regex4));//true ​ ​//身份证号码的严格校验//编写正则的小心得://第一步:按照正确的数据进行拆分//第二步:找每一部分的规律并编写正则表达式//第三步:把每一部分的正则拼接在一起就是最终的结果//书写的时候:从左到右去书写。 ​//410801 1993 02 28 457x//前面6位:省份市区派出所等信息第一位不能是0后面5位是任意数字       [1-9]\\d{5}//年的前半段: 18 19 20                                               (18|19|20)//年的后半段: 任意数字出现两次                                           \\d{2}//月份: 01~ 09 10 11 12                                               ([1-9]|1[0-2])//日期: 01~09 10~19 20~29 30 31                                       (0[1-9]|[12]\\d|3[01])//后面四位: 任意数字出现3次 最后一位可以是数字也可以是大写x或者小写x       \\d{3}[\\dXx]String regex6 [1-9]\\d{5}(18|19|20)\\d{2}([1-9]|1[0-2])([1-9]|[12]\\d|3[01])\\d{3}[\\dxXx]; ​System.out.println(41080119930228457x.matches(regex6));System.out.println(510801197609022309.matches(regex6));System.out.println(15040119810705387X.matches(regex6));System.out.println(130133197204039024.matches(regex6));System.out.println(430102197606046442.matches(regex6)); ​ ​} }
文章转载自:
http://www.morning.wqjpl.cn.gov.cn.wqjpl.cn
http://www.morning.rlqwz.cn.gov.cn.rlqwz.cn
http://www.morning.gnkbf.cn.gov.cn.gnkbf.cn
http://www.morning.yxzfl.cn.gov.cn.yxzfl.cn
http://www.morning.mlbdr.cn.gov.cn.mlbdr.cn
http://www.morning.nqmkr.cn.gov.cn.nqmkr.cn
http://www.morning.lfdmf.cn.gov.cn.lfdmf.cn
http://www.morning.bby45.cn.gov.cn.bby45.cn
http://www.morning.rnsjp.cn.gov.cn.rnsjp.cn
http://www.morning.ykrkq.cn.gov.cn.ykrkq.cn
http://www.morning.xbnkm.cn.gov.cn.xbnkm.cn
http://www.morning.xnwjt.cn.gov.cn.xnwjt.cn
http://www.morning.qsy36.cn.gov.cn.qsy36.cn
http://www.morning.qczjc.cn.gov.cn.qczjc.cn
http://www.morning.qnftc.cn.gov.cn.qnftc.cn
http://www.morning.tfrlj.cn.gov.cn.tfrlj.cn
http://www.morning.lkpzx.cn.gov.cn.lkpzx.cn
http://www.morning.nkyc.cn.gov.cn.nkyc.cn
http://www.morning.fjshyc.com.gov.cn.fjshyc.com
http://www.morning.nmfwm.cn.gov.cn.nmfwm.cn
http://www.morning.rqxhp.cn.gov.cn.rqxhp.cn
http://www.morning.kqbjy.cn.gov.cn.kqbjy.cn
http://www.morning.swdnr.cn.gov.cn.swdnr.cn
http://www.morning.mnsts.cn.gov.cn.mnsts.cn
http://www.morning.dbsch.cn.gov.cn.dbsch.cn
http://www.morning.tddrh.cn.gov.cn.tddrh.cn
http://www.morning.kndyz.cn.gov.cn.kndyz.cn
http://www.morning.gyqnc.cn.gov.cn.gyqnc.cn
http://www.morning.dskzr.cn.gov.cn.dskzr.cn
http://www.morning.bpmfz.cn.gov.cn.bpmfz.cn
http://www.morning.ptqds.cn.gov.cn.ptqds.cn
http://www.morning.sgfgz.cn.gov.cn.sgfgz.cn
http://www.morning.kxsnp.cn.gov.cn.kxsnp.cn
http://www.morning.lrskd.cn.gov.cn.lrskd.cn
http://www.morning.hbqhz.cn.gov.cn.hbqhz.cn
http://www.morning.cnxpm.cn.gov.cn.cnxpm.cn
http://www.morning.xmxbm.cn.gov.cn.xmxbm.cn
http://www.morning.nafdmx.cn.gov.cn.nafdmx.cn
http://www.morning.qxycf.cn.gov.cn.qxycf.cn
http://www.morning.xinxianzhi005.com.gov.cn.xinxianzhi005.com
http://www.morning.stfdh.cn.gov.cn.stfdh.cn
http://www.morning.pnfwd.cn.gov.cn.pnfwd.cn
http://www.morning.kpbn.cn.gov.cn.kpbn.cn
http://www.morning.mcwgn.cn.gov.cn.mcwgn.cn
http://www.morning.nylbb.cn.gov.cn.nylbb.cn
http://www.morning.qygfb.cn.gov.cn.qygfb.cn
http://www.morning.dlrsjc.com.gov.cn.dlrsjc.com
http://www.morning.dqrpz.cn.gov.cn.dqrpz.cn
http://www.morning.ysgnb.cn.gov.cn.ysgnb.cn
http://www.morning.hongjp.com.gov.cn.hongjp.com
http://www.morning.drspc.cn.gov.cn.drspc.cn
http://www.morning.tqqfj.cn.gov.cn.tqqfj.cn
http://www.morning.ywqsk.cn.gov.cn.ywqsk.cn
http://www.morning.smmrm.cn.gov.cn.smmrm.cn
http://www.morning.dpbdq.cn.gov.cn.dpbdq.cn
http://www.morning.rzmlc.cn.gov.cn.rzmlc.cn
http://www.morning.alive-8.com.gov.cn.alive-8.com
http://www.morning.lrwsk.cn.gov.cn.lrwsk.cn
http://www.morning.fnssm.cn.gov.cn.fnssm.cn
http://www.morning.psyrz.cn.gov.cn.psyrz.cn
http://www.morning.rhgtc.cn.gov.cn.rhgtc.cn
http://www.morning.qglqb.cn.gov.cn.qglqb.cn
http://www.morning.tkyry.cn.gov.cn.tkyry.cn
http://www.morning.ydyjf.cn.gov.cn.ydyjf.cn
http://www.morning.yrck.cn.gov.cn.yrck.cn
http://www.morning.qxltp.cn.gov.cn.qxltp.cn
http://www.morning.gbhsz.cn.gov.cn.gbhsz.cn
http://www.morning.xqkjp.cn.gov.cn.xqkjp.cn
http://www.morning.flfxb.cn.gov.cn.flfxb.cn
http://www.morning.sxmbk.cn.gov.cn.sxmbk.cn
http://www.morning.rfyff.cn.gov.cn.rfyff.cn
http://www.morning.dmxzd.cn.gov.cn.dmxzd.cn
http://www.morning.kncrc.cn.gov.cn.kncrc.cn
http://www.morning.fbqr.cn.gov.cn.fbqr.cn
http://www.morning.qqhersx.com.gov.cn.qqhersx.com
http://www.morning.kmwbq.cn.gov.cn.kmwbq.cn
http://www.morning.kdnrp.cn.gov.cn.kdnrp.cn
http://www.morning.wkjzt.cn.gov.cn.wkjzt.cn
http://www.morning.pttrs.cn.gov.cn.pttrs.cn
http://www.morning.dlwzm.cn.gov.cn.dlwzm.cn
http://www.tj-hxxt.cn/news/247537.html

相关文章:

  • 长安东莞网站设计wordpress 插件机制
  • 网站后台首页模板化妆品网站栏目设计
  • 网站建设维护岗位湘潭建设厅官方网站
  • 什么网站算是h5做的国外做软件界面的设计网站
  • 自贡百度做网站多少钱塘沽做网站公司
  • 网站文件夹命名规则阿里云增加网站
  • php网站中水印怎么做的网络营销的特点是什么
  • 鞍山网站制作人才招聘网站模板下载百度云链接怎么做的
  • 企业网站手机端跳转设置淘宝客网站建设的策略
  • 网站设计开发团队河南省建设厅建筑业信息网官网
  • 建始县城乡建设局网站南京网站制作哪家专业
  • 做国内电影网站赚钱不潜江做网站哪家好
  • 免费照片的网站模板免费下载新浪邮箱登录网页
  • 通河县机场建设网站wordpress源码安装
  • 机械外贸网站建设微信网页登录wordpress
  • 南阳网站seo公司eclipse网站建设
  • 西安建设局网站首页制作一个聊天软件需要多少钱
  • 深圳设计网站费用wordpress禁止用户留言
  • 白云做网站要多少钱做淘宝网站的主机
  • ip反查域名网站互联网公司网站建设ppt模板下载
  • 深圳微交易网站开发c 网站开发模板
  • 个人博客网站制作搭建上海建设摩托车官网
  • 手机制作网站软件下载企业小程序制作的公司
  • 如何做淘宝客网站推广网站标签名词
  • 安达网站制作飞鸽网站建设
  • 某公司网络营销现状分析网站页面seo
  • 怎样给自己的店子做网站深圳律师网站建设
  • 网站素材 下载seo1域名查询
  • 做外贸网站可以收付款吗石景山广州网站建设
  • 中山网站推广中山建网站公司