Python学习笔记第十八周

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python学习笔记第十八周相关的知识,希望对你有一定的参考价值。

目录:

  一、JavaScript正则表达式

 

 

内容:

  一、JavaScript正则表达式

    1、test   

    判断字符串是否符合规定的正则表达式

    例子:

    rep = /^\d+$/

    rep.test(‘123‘)返回true

 

    2、exec

    获取匹配的数据,在匹配时,默认只能匹配到第一个即返回,且匹配值以数组形式存在

    例子:分组匹配,会匹配两次,第一次匹配整体,第二次会将分组内容单独匹配出来

test = ‘JavaScript is more fun than Java or JavaBeans!‘
"JavaScript is more fun than Java or JavaBeans!"
var pattern = /\bJava\w*\b/
undefined
pattern.exec(test)
输出:["JavaScript", index: 0, input: "JavaScript is more fun than Java or JavaBeans!"]

var pattern = /\bJava(\w*)\b/
pattern.exec(test)
输出:(2) ["JavaScript", "Script", index: 0, input: "JavaScript is more fun than Java or JavaBeans!"]

  例子2:全局匹配 在匹配模板后面加g

  

技术分享
test = ‘JavaScript is more fun than Java or JavaBeans!‘
"JavaScript is more fun than Java or JavaBeans!"
var pattern = /\bJava\w*\b/g
undefined
pattern.exec(test)
["JavaScript", index: 0, input: "JavaScript is more fun than Java or JavaBeans!"]
pattern.exec(test)
["Java", index: 28, input: "JavaScript is more fun than Java or JavaBeans!"]
pattern.exec(test)
["JavaBeans", index: 36, input: "JavaScript is more fun than Java or JavaBeans!"]
没有加分组的情况
技术分享
var pattern = /\bJava(\w*)\b/g
undefined
test = ‘JavaScript is more fun than Java or JavaBeans!‘
"JavaScript is more fun than Java or JavaBeans!"
pattern.exec(test)
(2) ["JavaScript", "Script", index: 0, input: "JavaScript is more fun than Java or JavaBeans!"]
pattern.exec(test)
(2) ["Java", "", index: 28, input: "JavaScript is more fun than Java or JavaBeans!"]
pattern.exec(test)
(2) ["JavaBeans", "Beans", index: 36, input: "JavaScript is more fun than Java or JavaBeans!"]
有分组的情况

 

    

 

  二、BootStrap

    - CSS

    - JS

  

  

 

以上是关于Python学习笔记第十八周的主要内容,如果未能解决你的问题,请参考以下文章

杨玲 201771010133《面向对象程序设计(java)》第十八周学习总结

达拉草201771010105《面向对象程序设计(java)》第十八周学习总结

201771010108 -韩腊梅-第十八周学习总结

201771010111 李瑞红《第十八周学习总结》

201671010118 2016-2017-2《Java程序设计》 第十八周学习心得

狄慧201771010104《面向对象程序设计(java)》第十八周学习总结