JS正则
test:判断字符串是否符合规定的正则
rep = /d+/;
rep.test("asdfoiklfasdf89asdfasdf")
# true
rep = /^d+$/;
rep.test("asdfoiklfasdf89asdfasdf")
# true
Script:获取匹配的数据
rep = /d+/;
str = "wangshen_67_houyafa_20"
rep.exec(str)
# ["67"]
JavaScript is more fun than Java or JavaBeans!
var pattern = /Java(w*)/;
# ["JavaScript", "Script"]
JavaScript is more fun than Java or JavaBeans!
var pattern = /Javaw*/g;
# ["JavaScript"]
# ["Java"]
# ["JavaBeans"]
# null
JavaScript is more fun than Java or JavaBeans!
var pattern = /Java(w*)/g;
# ["JavaScript",'Script']
# ["Java", ""]
# ["JavaBeans", "Beans"]
# null
JavaScript is more fun than Java or JavaBeans!
var pattern = /Java(w*)/g;
这个会先打印出匹配到的字符串,如:JavaScript,并打印出()匹配到的如:Script。
多行匹配:
默认就是多行匹配
但是不能匹配第二行的^和$,使用m参数即可解决此问题,/.../m 表示多行匹配
标签事件执行顺序
默认事件先执行:
checkbox
//先把checkbox的值变成true或false再执行自定义事件
自定义先执行
a
submit
...
//这些都是自定义的事件先执行