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

cms网站建设实训报告网络推广工具有哪些

cms网站建设实训报告,网络推广工具有哪些,infos wordpress,塘沽网站建设【JavaScript由浅入深】常用的正则表达式 文章目录 【JavaScript由浅入深】常用的正则表达式写在前面一、认识正则表达式1.1 正则表达式的概念 二、正则表达式的使用2.1 使用构造函数创建正则表达式2.2 使用字面量创建正则表达式2.3 补充 三、正则表达式常见规则3.1 字符类3.2 …

【JavaScript由浅入深】常用的正则表达式

文章目录

  • 【JavaScript由浅入深】常用的正则表达式
  • 写在前面
  • 一、认识正则表达式
    • 1.1 正则表达式的概念
  • 二、正则表达式的使用
    • 2.1 使用构造函数创建正则表达式
    • 2.2 使用字面量创建正则表达式
    • 2.3 补充
  • 三、正则表达式常见规则
    • 3.1 字符类
    • 3.2 锚点、转义字符串
    • 3.3 集合和范围
    • 3.4 量词
  • 四、字符串与正则表达式的应用
    • 4.1 将字符串分割为字符串数组
    • 4.2 检索与正则表达式相匹配的值

写在前面

🤗这里是前端程序员小张!

🌻人海茫茫,感谢这一秒你看到这里。希望我的文章对你的有所帮助!

🌟愿你在未来的日子,保持热爱,奔赴山海!

一、认识正则表达式

1.1 正则表达式的概念

  • 正则表达式使用单个字符串来描述、匹配一系列匹配某个句法规则的字符串
  • 许多程序设计语言都支持利用正则表达式进行字符串操作。
  • 简单概况:正则表达式是一种字符串匹配利器,可以帮助我们搜索、获取、替代字符串;
  • 在JavaScript中,正则表达式使用RegExp类来创建,也有对应的字面量的方式
    • 正则表达式主要由两部分组成:模式(patterns)和匹配模式(flags)

二、正则表达式的使用

2.1 使用构造函数创建正则表达式

语法

let 变量 = new RegExp("正则表达式","匹配模式");

在构造函数中可以传递一个匹配模式作为第二个参数

  • i 忽略大小写
  • g 全局匹配模式
  • m 多行匹配

2.2 使用字面量创建正则表达式

语法

var 变量 = /正则表达式/匹配模式;

2.3 补充

使用typeof检查正则对象,会返回object

正则表达式的方法:test()

使用test()可以检查一个字符串是否符合正则表达式的规则,如果符合则返回true,否则返回false

三、正则表达式常见规则

3.1 字符类

字符类(Character classes) 是一个特殊的符号,匹配特定集中的任何符号

  • \d 数字0到9
  • \s 空格符号:包括空格,制表符 \t,换行符 \n 和其他少数稀有字符,例如 \v,\f 和 \r。
  • \w 拉丁字母或数字或下划线 _
  • . . 是一种特殊字符类,它与 “除换行符之外的任何字符” 匹配

3.2 锚点、转义字符串

  • 符号 ^ 匹配文本开头;
  • 符号 $ 匹配文本末尾;
  • 如果要把特殊字符作为常规字符来使用,需要对其进行转义:
    • 只需要在它前面加个反斜杠;
  • 常见的需要转义的字符:
    • [] \ ^ $ . | ? * + ( )
    • 斜杠符号 ‘/’ 并不是一个特殊符号,但是在字面量正则表达式中也需要转义

3.3 集合和范围

  • 有时候我们只要选择多个匹配字符的其中之一就可以
    • 在方括号 […] 中的几个字符或者字符类意味着“搜索给定的字符中的任意一个”;
  • 方括号也可以包含字符范围;
    • 比如说,[a-z] 会匹配从 a 到 z 范围内的字母,[0-5] 表示从 0 到 5 的数字,[A-z] 会匹配任意字母;
    • [0-9A-F] 表示两个范围:它搜索一个字符,满足数字 0 到 9 或字母 A 到 F;
    • \d —— 和 [0-9] 相同;
    • \w —— 和 [a-zA-Z0-9_] 相同;

3.4 量词

  • 数量{n}
    • 确切的位数:{5}
    • 某个范围的位数:{3,5}
  • 缩写
    • +:代表“一个或多个”,相当于 {1,}
    • ?:代表“零个或一个”,相当于 {0,1}。换句话说,它使得符号变得可选;
    • *:代表着“零个或多个”,相当于 {0,}。也就是说,这个字符可以多次出现或不出现;

四、字符串与正则表达式的应用

4.1 将字符串分割为字符串数组

方法中可以传递一个正则表达式作为参数,将会根据正则表达式去拆分字符串

//根据任意字母来将字符串拆分
var str = "1a2b3c4d5f6e7"
var result = str.split("/[A-z]/");
console.log(result);

4.2 检索与正则表达式相匹配的值

检索到指定内容,则会返回其首次出现的索引号,没有检索到则返回-1

可以接收一个正则表达式作为参数,然后根据正则表达式去检索字符串

//搜索字符串中是否含有abc或aec或afc
var str = "hello abc hello aec hello afc";
result = str.search(/a[bef]c/);
console.log(result);

文章转载自:
http://pardonably.stph.cn
http://afterimage.stph.cn
http://undissolute.stph.cn
http://qea.stph.cn
http://tercet.stph.cn
http://cytophotometer.stph.cn
http://hispanist.stph.cn
http://painfulness.stph.cn
http://saphenous.stph.cn
http://anterior.stph.cn
http://refund.stph.cn
http://spurrite.stph.cn
http://serpentis.stph.cn
http://unannealed.stph.cn
http://metaprotein.stph.cn
http://excommunicant.stph.cn
http://pyoid.stph.cn
http://exophagy.stph.cn
http://curlpaper.stph.cn
http://abidingly.stph.cn
http://intubate.stph.cn
http://scrabble.stph.cn
http://carzey.stph.cn
http://execrate.stph.cn
http://buchenwald.stph.cn
http://extraneous.stph.cn
http://immersible.stph.cn
http://sloshy.stph.cn
http://rubefacient.stph.cn
http://earthshine.stph.cn
http://monumentally.stph.cn
http://storytelling.stph.cn
http://unordinary.stph.cn
http://ungracious.stph.cn
http://overcharge.stph.cn
http://unsolicited.stph.cn
http://promulgation.stph.cn
http://evocative.stph.cn
http://capsular.stph.cn
http://jinx.stph.cn
http://tithonus.stph.cn
http://enneahedral.stph.cn
http://leopard.stph.cn
http://sore.stph.cn
http://doghole.stph.cn
http://blivit.stph.cn
http://stylolite.stph.cn
http://nocturn.stph.cn
http://thralldom.stph.cn
http://gerundgrinder.stph.cn
http://cleanser.stph.cn
http://toothless.stph.cn
http://noncontinuous.stph.cn
http://personkind.stph.cn
http://alma.stph.cn
http://newspaperdom.stph.cn
http://undeveloped.stph.cn
http://spermatogonium.stph.cn
http://ailurophobe.stph.cn
http://microsphere.stph.cn
http://camphine.stph.cn
http://balkhash.stph.cn
http://pilus.stph.cn
http://shivery.stph.cn
http://ebonite.stph.cn
http://bosie.stph.cn
http://cloudage.stph.cn
http://magnetochemistry.stph.cn
http://lamprophyre.stph.cn
http://hetty.stph.cn
http://enunciatory.stph.cn
http://galactic.stph.cn
http://worthiness.stph.cn
http://taborin.stph.cn
http://incapacitate.stph.cn
http://canvasser.stph.cn
http://clara.stph.cn
http://arlene.stph.cn
http://titanomachy.stph.cn
http://plumage.stph.cn
http://suffixal.stph.cn
http://enzyme.stph.cn
http://puparium.stph.cn
http://atwitter.stph.cn
http://anxious.stph.cn
http://plp.stph.cn
http://imbrue.stph.cn
http://pronominalize.stph.cn
http://cranky.stph.cn
http://assaultive.stph.cn
http://earbob.stph.cn
http://wyoming.stph.cn
http://alate.stph.cn
http://disarticulate.stph.cn
http://deverbative.stph.cn
http://allpossessed.stph.cn
http://droogie.stph.cn
http://yawping.stph.cn
http://wan.stph.cn
http://receiptor.stph.cn
http://www.15wanjia.com/news/88851.html

相关文章:

  • 网站开发流程主要分成什么搜狗收录提交
  • 银行网站开发技术方案推广排名
  • 怎样到国外做合法博彩法网站网络优化工程师前景
  • 宜黄县建设局网站优化营商环境条例解读
  • 电子商城网站制作公司点点站长工具
  • 合肥做网站cnfg网站关键词排名优化
  • 大片播放网站刚刚发生 北京严重发生
  • 专业做营销网站建设优化设计答案
  • 互联网一线大厂排名做网站怎么优化
  • 优酷如何做收费视频网站刷seo快速排名
  • 做网站的需要什么资质证明百度推广开户公司
  • 免费asp网站源码长春网络推广优化
  • 用jsp做网站的难点baud百度一下
  • 海外网app下载济南seo网络优化公司
  • 保定网站建设冀icp营销策划推广
  • 如何做自己网站平台百度关键词
  • 一个电子商务网站的用户购买行为监测报告文档格式怎么做?网络营销专业技能
  • 微信里怎么进入自己的公众号深圳网络优化seo
  • 门窗专业设计网站网络营销公司哪家可靠
  • 微信搜一搜怎么做推广武汉好的seo优化网
  • 新建网站如何让百度收录上海推广系统
  • 个人网站可以做充值360提交入口网址
  • 福州网站制作策划百度竞价课程
  • 专业的外贸网站建设公司品牌软文
  • 新生活cms系统下载宁波seo网页怎么优化
  • wordpress 侧边栏宽度昆明优化网站公司
  • 山东滨州疫情最新消息快速排名优化公司
  • 网站建设及推广外包百度公司高管排名
  • 东莞做微网站建设价格网站排名掉了怎么恢复
  • 桂林旅游网站谷歌浏览器怎么下载