测试正则匹配
//定义正则
var emailFormat=/^[a-zA-Z0-9]+@[a-zA-Z0-9]+\.[a-zA-Z0-9]+$/
//匹配正则
emailFormat.test('admin@demo.com')
输出:true
正则提取组,按照()提取
//定义正则
var emailFormat=/^([a-zA-Z0-9]+)@[a-zA-Z0-9]+\.[a-zA-Z0-9]+$/
//提取组
emailFormat.exec('admin@demo.com')
输出:
(2) ["admin@demo.com", "admin", index: 0, input: "admin@demo.com", groups: undefined]