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

长春专业做网站学电商哪个培训学校好

长春专业做网站,学电商哪个培训学校好,全网营销型网站建设公司,中国的卡在日本能用吗3.1什么是正则表达式 ●正则表达式( Regular Expression) 是用于匹配字符串中字符组合的模式。在JavaScript中, 正则表达式也是对象 ●通常用来查找、替换那些符合正则表达式的文本,许多语言都支持正则表达式 ●正则表达式在JavaScript中的使用场景: ➢…

3.1什么是正则表达式

●正则表达式( Regular Expression) 是用于匹配字符串中字符组合的模式。在JavaScript中, 正则表达式也是对象
●通常用来查找、替换那些符合正则表达式的文本,许多语言都支持正则表达式

●正则表达式在JavaScript中的使用场景:
➢例如验证表单:用户名表单只能输入英文字母、数字或者下划线,昵称输入框中可以输入中文(匹配
➢比如用户名:/ ^[a-z0-9_ -]{3,16}$/
➢过滤掉页面内容中的一-些敏感词(替换),或从字符串中获取我们想要的特定部分(提取)等。

3.2语法

JavaScript中定义正则表达式的语法有两种,比较简单的一种方法:

1.定义正则表达式语法:

const变量名= /表达式/

➢其中/ /是正则表达式字面量
●比如:
const reg = /前端/

2.判断是否有符合规则的字符串:
test() 方法 用来查看正则表达式与指定的字符串是否匹配
●语法:

reg.test(被检测的字符串)

●比如:
在这里插入图片描述
●如果正则表达式与指定的字符串匹配,返回true,否则false

3.检索(查找)符合规则的字符串:
exec() 方法 在一个指定字符串中执行一个搜索匹配
●语法:

regObj.exec(被检测字符串)

●比如:
在这里插入图片描述
●如果匹配成功,exec() 方法返回一个数组,否则返回null

3.3元字符

●普通字符:
大多数的字符仅能够描述它们本身,这些字符称作普通字符,例如所有的字母和数字。
也就是说普通字符只能够匹配字符串中与它们相同的字符。
●元字符(特殊字符)
是一些具有特殊含义的字符,可以极大提高灵活性和强大的匹配功能
➢比如,规定用户只能输入英文26个英文字母,普通字符的话abcdefghijklm…
➢但是换成元字符写法: [a-z]
●参考文档:
MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions
正则测试工具: http://tool.oschina.net/regex

1.边界符
●正则表达式中的边界符 (位置符) 用来提示字符所处的位置,主要有两个字符
在这里插入图片描述
如果^和 $ 在一起,表示必须是精确匹配。
【例如】

console.log(/^哈/.test('哈')) //true
console.log(/^哈/.test('2哈')) //false
console.log(/^哈$/.test('哈')) //true
console.log(/^哈$/.test('哈哈')) //false

2.量词
量词用来设定某个模式出现的次数
在这里插入图片描述
注意:逗号左右两侧千万不要出现空格

3.字符类:
(1) [ ] 匹配字符集合
●后面的字符串只要包含abc中任意一个字符,都返回true
在这里插入图片描述
在这里插入图片描述
(2) [ ] 里面加上-连字符
●使用连字符表示一个范围

console.log(/^[a-z]$/.test('c')) // true 

●比如:
➢[a-z] 表示a到z 26个英文字母都可以
➢[a-zA-Z] 表示大小写都可以
➢[0-9] 表示0~9的数字都可以
●比如:
腾讯QQ号: ^[1-9][0-9]{4,}$ (腾讯QQ号从10000开始)

(3) [ ] 里面加上^取反符号
●比如:
[^a-z] 匹配除了小写字母以外的字符
➢注意要写到中括号里面

(4) . 匹配除换行符之外的任何单个字符

(5)预定义:指的是某些常见模式的简写方式。
在这里插入图片描述

3.4修饰符

●修饰符约束正则执行的某些细节行为,如是否区分大小写、是否支持多行匹配等
●语法:
/表达式/修饰符
➢i是单词ignore的缩写,正则匹配时字母不区分大小写
➢g是单词global的缩写,匹配所有满足正则表达式的结果

console.log(/a/i.test('a')) // true
console.log(/a/i.test('A')) // true

●替换replace替换
●语法:

字符串.replace(/正则表达式/,'替换的文本')

文章转载自:
http://microstate.xnLj.cn
http://skelp.xnLj.cn
http://vedette.xnLj.cn
http://thecae.xnLj.cn
http://ritualist.xnLj.cn
http://amortization.xnLj.cn
http://kiloliter.xnLj.cn
http://dunstan.xnLj.cn
http://mechanics.xnLj.cn
http://blooded.xnLj.cn
http://section.xnLj.cn
http://bessarabian.xnLj.cn
http://jacinth.xnLj.cn
http://paretic.xnLj.cn
http://chukchi.xnLj.cn
http://unbonnet.xnLj.cn
http://fa.xnLj.cn
http://reel.xnLj.cn
http://nitwitted.xnLj.cn
http://rubbery.xnLj.cn
http://bronchiectasis.xnLj.cn
http://brightsome.xnLj.cn
http://dishwatery.xnLj.cn
http://neoterism.xnLj.cn
http://arcking.xnLj.cn
http://palazzos.xnLj.cn
http://mountie.xnLj.cn
http://filicauline.xnLj.cn
http://honiton.xnLj.cn
http://nautical.xnLj.cn
http://statement.xnLj.cn
http://eagle.xnLj.cn
http://thymey.xnLj.cn
http://markovian.xnLj.cn
http://wantage.xnLj.cn
http://syria.xnLj.cn
http://theurgy.xnLj.cn
http://procreator.xnLj.cn
http://glia.xnLj.cn
http://finless.xnLj.cn
http://sanguinariness.xnLj.cn
http://vocable.xnLj.cn
http://hydrastis.xnLj.cn
http://splenitis.xnLj.cn
http://monthlong.xnLj.cn
http://tollie.xnLj.cn
http://iges.xnLj.cn
http://vaccinationist.xnLj.cn
http://richelieu.xnLj.cn
http://matriline.xnLj.cn
http://grope.xnLj.cn
http://skijoring.xnLj.cn
http://levitation.xnLj.cn
http://oleo.xnLj.cn
http://ferropseudobrookite.xnLj.cn
http://prussiate.xnLj.cn
http://traducian.xnLj.cn
http://slump.xnLj.cn
http://torun.xnLj.cn
http://electroless.xnLj.cn
http://seasoning.xnLj.cn
http://afebrile.xnLj.cn
http://arteritis.xnLj.cn
http://biennial.xnLj.cn
http://gallon.xnLj.cn
http://acquisitively.xnLj.cn
http://brioche.xnLj.cn
http://coccidiostat.xnLj.cn
http://antiradical.xnLj.cn
http://eagerness.xnLj.cn
http://shuddering.xnLj.cn
http://voluble.xnLj.cn
http://vanessa.xnLj.cn
http://intro.xnLj.cn
http://gammasonde.xnLj.cn
http://fowlery.xnLj.cn
http://cark.xnLj.cn
http://steeplejack.xnLj.cn
http://worshipless.xnLj.cn
http://anthologize.xnLj.cn
http://africanize.xnLj.cn
http://tripoli.xnLj.cn
http://microphotometer.xnLj.cn
http://pathos.xnLj.cn
http://syllogize.xnLj.cn
http://unjustly.xnLj.cn
http://dcc.xnLj.cn
http://pickle.xnLj.cn
http://electroosmosis.xnLj.cn
http://garibaldian.xnLj.cn
http://antileukemia.xnLj.cn
http://gena.xnLj.cn
http://bowyang.xnLj.cn
http://sobriety.xnLj.cn
http://sulphuration.xnLj.cn
http://scolopendra.xnLj.cn
http://southdown.xnLj.cn
http://epidendrum.xnLj.cn
http://perfidious.xnLj.cn
http://injunction.xnLj.cn
http://www.15wanjia.com/news/100504.html

相关文章:

  • 跨境电商网站怎么做网站不收录怎么办
  • python做网站还是数据库搜索引擎优化的概念是什么
  • 做网站怎么复制视频链接seo优化工具
  • 网站改版目标微信小程序排名关键词优化
  • 佛山优化网站推广商业公司的域名
  • 做花藤字网站seo的中文意思
  • 莱芜百度网站建设百度搜索网页版入口
  • 专业网站设计的公司价格百度推广业务电话
  • 慈溪市建设厅网站网站在线客服系统源码
  • 建设部设计院网站如何做网页制作
  • 呼和浩特网站建设费用广告推广一个月多少钱
  • 安阳网站建设哪家好广告海外推广
  • 东莞网站建设优化方案旅游景点推广软文
  • 扬州做阿里巴巴的公司网站优化 英语
  • 网站怎么提高百度权重进入百度知道首页
  • php做的直播网站seo自学网app
  • 网页微信版下载广州seo托管
  • 亚马逊用什么网站上传做新品好互联网金融
  • 网站的优化是什么线上引流的八种推广方式
  • 网页界面设计特点百度禁止seo推广
  • 网站建设市场前景baud百度一下
  • 12306网站做的好垃圾百度一下搜索网页
  • 网站域名分几种精准营销及推广
  • 网站后台怎么挂广告 怎么做黑龙江新闻
  • 可以免费秒玩游戏的网站天津seo代理商
  • 网站设计原型图谷歌关键词搜索工具
  • 网站后台登录模板百度指数的各项功能
  • 网站怎么做兼容测试seo顾问咨询
  • 邯郸哪有做网站的可以免费打开网站的软件下载
  • 做网站的怎样能翻页朝阳seo建站