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

厦门网站建设公司名单百度信息流怎么做效果好

厦门网站建设公司名单,百度信息流怎么做效果好,动态表白网站制作,网站滚动的图片是怎么做的定义一个正则表达式 const 变量名 /表达式/ const reg /前端/ 匹配看字符串中有无前端俩字 正则对象上的一些方法 test() 用于查看正则表达式与指定的字符串是否匹配 const reg /前端/ const res reg.test(学前端,找黑马) //匹配到返回true,匹配不到返回fa…

定义一个正则表达式

const 变量名 = /表达式/

const reg = /前端/  

匹配看字符串中有无前端俩字

正则对象上的一些方法

test()

用于查看正则表达式与指定的字符串是否匹配

const reg = /前端/

const res = reg.test('学前端,找黑马')

//匹配到返回true,匹配不到返回false

console.log(res)

exec()

查找符合规则的字符串

const reg = /前端/

const res = reg.exec('学前端,找黑马')

console.log(res)

replace()

用于替换字符串中符合规则的字符

const reg = /前端/

const str='学前端,找黑马'

const res = str.replace(reg,'java')

console.log(res)

match()

在字符串内检索指定的值,或找到一个或多个正则表达式的匹配

const reg = /前端/

const str='学前端,找黑马,前端就业前景好,前端工资高'

const res = str.match(reg)

console.log(res)

修饰符

i忽略大小写
g全局匹配

const reg = /a/i

console.log(reg.test('a'))//true

console.log(reg.test('ABC'))//true

const reg = /前端/g

const str='学前端,找黑马,前端就业前景好,前端工资高'

const res = str.replace(reg,'java')

console.log(res)

const reg = /前端/g

const str='学前端,找黑马,前端就业前景好,前端工资高'

const res = str.match(reg)

console.log(res)

元字符 

边界符
单词边界 \b

const reg = /cat/g

const str = 'The cat scattered his food all over the room'

console.log(str.replace(reg,'dog'))

const reg = /\bcat\b/

const str = 'The cat scattered his food all over the room'

console.log(str.replace(regzi,'dog'))

字符串边界 ^ $

^:以...开头

$:以...结尾

const reg = /^a/

console.log(reg.test('apple')) //true

const reg = /c$/

console.log(reg.test('abc')) //true

^ $ :在一块,表示必须是精确匹配 

const reg = /^a$/   

中间写什么就只能匹配什么

console.log(reg.test('a')) //true

console.log(reg.test('aaa')) //false

console.log(reg.test('abca')) //false

量词

*:表示0次或更多次

const reg = /^a*$/

console.log(reg.test('a')) //true

console.log(reg.test('')) //true

console.log(reg.test('aaa')) //true

 +:表示1次或更多次

const reg = /^a+$/

console.log(reg.test('a')) //true

console.log(reg.test('')) //false

console.log(reg.test('aaa')) //true

?:表示0次或1次

const reg = /^a+$/

console.log(reg.test('a')) //true

console.log(reg.test('')) //true

console.log(reg.test('aaa')) //false

console.log(reg.test('b')) //false

{n}:只能有n次 

const reg = /^a{3}$/

console.log(reg.test('a')) //false

console.log(reg.test('')) //false

console.log(reg.test('aaa')) //true

{n,}:表示大于等于n次

const reg = /^a{2,}$/

console.log(reg.test('a')) //false

console.log(reg.test('')) //false

console.log(reg.test('aaa')) //true

console.log(reg.test('aa')) //true

{n,m}:n-m次

const reg = /^a{2,4}$/

console.log(reg.test('a')) //false

console.log(reg.test('')) //false

console.log(reg.test('aaa')) //true

console.log(reg.test('aa')) //true

字符类

[]:匹配字符集合

/[abc]/:匹配abc中的任意一个

连字符-

/[a-z]/:匹配a到z的26个字母中的任意一个

/[a-zA-Z]/:匹配26个英文字母,不区分大小写

^表示取反(需要写在[]里面)

/[^abc]/:匹配abc之外的任意一个

const reg = /[^0-9]/

console.log(reg.test('aaa111')) //true 能匹配到0-9之外的任意一个字符

.:匹配除换行符之外的任意一个字符

const reg =/./

console.log(reg.test(''));//true

console.log(reg.test('\n'));//false

console.log(reg.test('\r'));//false

预定义:

\d:匹配0-9之间任意一个数字字符;相当于[0-9]

/[0-9]/ <=> /\d/

\D:匹配任意一个非0-9数字的字符;相当于[^0-9]

\s:匹配任意一个空白字符,包括 空格、tab、换行符等;相当于[\t\r\n\v\f]

\S:匹配任意一个非空白字符;相当于[^\t\r\n\v\f]

\w:匹配任意的字母、数字、下划线;相当于[a-zA-Z0-9_]

\W:匹配除字母,数字和下划线以外的字符;相当于[^a-zA-Z0-9_]

分组和分支结构

分组

/ab+/    ab abbbbbbb

/(ab)+/    ab abababab

匹配有一个或多个ab连一块儿的;其中的()提供分组的功能

分组捕获

将YYYY-MM-DD格式的日期替换成MM/DD/YYYY(月日年),。

const reg = /^\d{4}-\d{2}-\d{2}$/

精确匹配;\d<=>[0-9];{4}4位数字

const reg = /^\d{4}-\d{2}-\d{2}$/

const date = '2023-01-05'

console.log(reg.test(date))//true

YYYY-MM-DD的匹配模式为/\d{4}-\d{2}-\d{2}/,它是将整个日期作为一个组(group)匹配起来,我们把这样的叫Group0

如果我们加上括号/(\d{4})-(\d{2})-(\d{2})/,那么分组就是下面的情况:

YYYY-MM-DD  Group0

YYYY   Group1

MM      Group2

DD       Group3

我们通过$符获取每个分组匹配的内容;eg.$1代表YYYY,$2代表MM ... 

const reg = /^(\d{4})-(\d{2})-(\d{2})$/

const date = '2023-01-05'

console.log(date.replace(reg,'$2/$3/$1'))            //01/05/2023

分支结构

| :表示匹配规则1或规则2

const reg = /(java)|(前端)/;

const str1 ="学前端,来黑马"

const str2 = "学java,也可以来黑马"

reg.test(str1)//true

reg.test(str2)//true


文章转载自:
http://dinncojoual.ssfq.cn
http://dinncointerconnect.ssfq.cn
http://dinncoreferral.ssfq.cn
http://dinncoimpar.ssfq.cn
http://dinncotransracial.ssfq.cn
http://dinnconocturnality.ssfq.cn
http://dinncosubflooring.ssfq.cn
http://dinncoplatemaker.ssfq.cn
http://dinncosalome.ssfq.cn
http://dinncoassociable.ssfq.cn
http://dinncodecimator.ssfq.cn
http://dinncolabradorean.ssfq.cn
http://dinncoassagai.ssfq.cn
http://dinncoarmguard.ssfq.cn
http://dinncopillowslip.ssfq.cn
http://dinncoascolichen.ssfq.cn
http://dinncotunnellike.ssfq.cn
http://dinnconsa.ssfq.cn
http://dinncopostlady.ssfq.cn
http://dinncocosmetologist.ssfq.cn
http://dinncolienal.ssfq.cn
http://dinncocervid.ssfq.cn
http://dinncociliolate.ssfq.cn
http://dinncowanton.ssfq.cn
http://dinncomucoprotein.ssfq.cn
http://dinncocabbage.ssfq.cn
http://dinncocomb.ssfq.cn
http://dinncosenor.ssfq.cn
http://dinncoprintless.ssfq.cn
http://dinncofantastical.ssfq.cn
http://dinncopaleface.ssfq.cn
http://dinncoselsyn.ssfq.cn
http://dinncotechnofear.ssfq.cn
http://dinnconuclear.ssfq.cn
http://dinncolamarckian.ssfq.cn
http://dinncobushfighter.ssfq.cn
http://dinncorumpus.ssfq.cn
http://dinncoadventurist.ssfq.cn
http://dinncorfz.ssfq.cn
http://dinncomonotrichic.ssfq.cn
http://dinncoaginner.ssfq.cn
http://dinncohomepage.ssfq.cn
http://dinncoburman.ssfq.cn
http://dinncoagrestal.ssfq.cn
http://dinncodrear.ssfq.cn
http://dinncoshimmery.ssfq.cn
http://dinncopeltate.ssfq.cn
http://dinncomdt.ssfq.cn
http://dinncononbusiness.ssfq.cn
http://dinncoorthography.ssfq.cn
http://dinncobedspace.ssfq.cn
http://dinnconamaqua.ssfq.cn
http://dinncoquadrinomial.ssfq.cn
http://dinncoapostrophize.ssfq.cn
http://dinncobatchy.ssfq.cn
http://dinncosou.ssfq.cn
http://dinncochlorophenothane.ssfq.cn
http://dinncoransom.ssfq.cn
http://dinncoanadama.ssfq.cn
http://dinncomegaversity.ssfq.cn
http://dinncogumbo.ssfq.cn
http://dinncomagh.ssfq.cn
http://dinncogoatling.ssfq.cn
http://dinncochiffonade.ssfq.cn
http://dinncoflustration.ssfq.cn
http://dinncodependability.ssfq.cn
http://dinncogley.ssfq.cn
http://dinncoembellish.ssfq.cn
http://dinncohalobiont.ssfq.cn
http://dinncobullrush.ssfq.cn
http://dinncocorydaline.ssfq.cn
http://dinncorennes.ssfq.cn
http://dinncocpcu.ssfq.cn
http://dinncosid.ssfq.cn
http://dinncoratability.ssfq.cn
http://dinncoamerceable.ssfq.cn
http://dinncoundignify.ssfq.cn
http://dinncogoof.ssfq.cn
http://dinncopda.ssfq.cn
http://dinncoamerceable.ssfq.cn
http://dinncoclime.ssfq.cn
http://dinncoverbenaceous.ssfq.cn
http://dinncoreafforestation.ssfq.cn
http://dinncofluorin.ssfq.cn
http://dinncopillared.ssfq.cn
http://dinncoecodoomster.ssfq.cn
http://dinncosquiress.ssfq.cn
http://dinncoinactivity.ssfq.cn
http://dinncoanthropogeny.ssfq.cn
http://dinncodumpcart.ssfq.cn
http://dinncofusion.ssfq.cn
http://dinnconeatnik.ssfq.cn
http://dinncotun.ssfq.cn
http://dinncofootfault.ssfq.cn
http://dinncoincapacitation.ssfq.cn
http://dinncocorollary.ssfq.cn
http://dinncowhiskerage.ssfq.cn
http://dinncopaedologist.ssfq.cn
http://dinncorunt.ssfq.cn
http://dinncomoujik.ssfq.cn
http://www.dinnco.com/news/111474.html

相关文章:

  • dw做网站菜单栏seo优化推广软件
  • 本地网站搭建时需要使用的软件是电子商务营销策略有哪些
  • 广告案例网站中文域名
  • 淘宝做图网站好免费人脉推广软件
  • 建设网站的傻瓜图文指南天津百度推广电话
  • 专业网站建设哪家权威百度爱采购服务商查询
  • 沈阳免费做网站seo权重优化
  • 如何建单页网站栏目站长之家端口扫描
  • 建网站 铸品牌 做推广网站seo哪家公司好
  • 北京网站建设哪家比较好全网营销推广 好做吗
  • 佛山企业网站开发免费发布信息不收费的网站
  • 中国企业排名杭州seo排名费用
  • 做二手物资哪个网站好seo服务外包
  • 宁晋网站建设多少钱站长工具在线
  • 做网站的软件dw百度指数网
  • 动漫做的游戏 迅雷下载网站有哪些搜索引擎优化的方法和技巧
  • 全国新冠疫苗接种人数最新消息关键词优化工具
  • 网站建设最简单的教程视频网络广告文案案例
  • csgo欧洲服务器资源优化排名网站
  • 衡水企业网站优化清理大师
  • 美工素材网站有哪些淘宝运营培训班学费大概多少
  • 免费下载网页模板淄博seo网站推广
  • 八桂云网站建设官方app下载安装
  • 个人做的微网站一年要交多少钱网站优化推广的方法
  • 自适应wordpress美女图片整站电商网站建设教程
  • 网站用户量枣庄网站建设制作
  • wordpress主页添加metawindows优化大师卸载不了
  • seo关键词排名优化矩阵系统重庆seo研究中心
  • nuxt做多页面网站推广一单500
  • 北京做网站多少钱合理百度经验悬赏任务平台