第十八节
一 、js正则
test - 判断是否符合规定的正则
exec - 获取匹配的数据
test
rep = /\d+/; /\d+/ rep.te undefined rep.test("dgdf343dgffddsf332") true rep.test("dsfssgd") false
rep = /^\d+$/ /^\d+$/ rep /^\d+$/ rep.test("123") true rep.test("123df") false
exec
rep = /\d+/ /\d+/ str = "dsfsd_ss235_324dfgd" "dsfsd_ss235_324dfgd" rep.exec(str) ["235", index: 8, input: "dsfsd_ss235_324dfgd"]
text = "Java is more fun than JavaScript and JavaBeans" "Java is more fun than JavaScript and JavaBeans" var pattern = /\bJava\w*\b/ undefined pattern.exec(text) ["Java", index: 0, input: "Java is more fun than JavaScript and JavaBeans"] # "\b"可以识别字符串的的空格,以字符串为分割;"\w"可以识别所有,不限数据类型;"\d"只识别数字。
text = "JavaScript is more fun than Java and JavaBeans" "JavaScript is more fun than Java and JavaBeans" var pattern = /\bJava(\w*)\b/ undefined pattern.exec(text) (2) ["JavaScript", "Script", index: 0, input: "JavaScript is more fun than Java and JavaBeans"] # 匹配Java开头的JavaScript,同时又对Script做了分离,以字符串列表的行书返回。
正则表达式
/..../ 用语定义正则表达式
/.../g 匹配整行
/.../i 不区分大小写
/.../m 多行匹配
var pattern = /\bJava\w*\b/gm 整行匹配
# 单行匹配 var pattern = /\bJava\w*\b/g undefined pattern.exec(text) ["JavaScript", index: 0, input: "JavaScript is more fun than Java and JavaBeans"] pattern.exec(text) ["Java", index: 28, input: "JavaScript is more fun than Java and JavaBeans"] pattern.exec(text) ["JavaBeans", index: 37, input: "JavaScript is more fun than Java and JavaBeans"] pattern.exec(text) # 多行匹配 var pattern = /^Java(\w*)/g undefined pattern.exec(text) (2) ["JavaScript", "Script", index: 0, input: "JavaScript is more fun than ↵Java and JavaBeans"] pattern.exec(text) null var pattern = /^Java(\w*)/gm undefined pattern.exec(text) (2) ["JavaScript", "Script", index: 0, input: "JavaScript is more fun than ↵Java and JavaBeans"] pattern.exec(text) (2) ["Java", "", index: 29, input: "JavaScript is more fun than ↵Java and JavaBeans"] pattern.exec(text) null
二、组件
BootStrap
- css
- js
easyUI
- css
- js
jQueryUI
- css
- js
1.js验证
# 创建django项目
django-admin startproject mysite
# mysite目录结构
mysite
- mysite # 对整个程序进行配置
- settings # 配置文件 # 注销csrf;添加templates路径;在文件尾配置static路径,STATICFILES_DIRS;
- url # url对应关系
- wsgi # 寻租wsgi规范,uwsgi + nginx
wsgi遵循很多规则,这些规则的本质是帮助django创建socket
- manager.py #管理django程序:
- python manage.py
- python manage.py startapp xx
# python自己的orm,管理自己的数据库。生成自己的类
- python manage.py makemigrations
- python manage.py migrate
# 在django项目中创建app
python manager.py startapp crm